summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-12-17 21:10:48 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-12-17 21:10:48 +0100
commit7f0a644f639e5e4ef9d6ed326df7b8ec833e7de4 (patch)
tree3a4e1437789bbc39cf3c0eb7d7af067b258461c5 /lib/DBInfoscreen.pm
parent4609b7312d67063b2cb0d5803260d7dc25475bc2 (diff)
set version via config
Diffstat (limited to 'lib/DBInfoscreen.pm')
-rw-r--r--lib/DBInfoscreen.pm43
1 files changed, 21 insertions, 22 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm
index 0ee9493..4fca3b6 100644
--- a/lib/DBInfoscreen.pm
+++ b/lib/DBInfoscreen.pm
@@ -20,10 +20,6 @@ use utf8;
no if $] >= 5.018, warnings => 'experimental::smartmatch';
-our $VERSION = qx{git describe --dirty} || '0.05';
-
-chomp $VERSION;
-
my %default = (
backend => 'iris',
mode => 'app',
@@ -33,6 +29,21 @@ my %default = (
sub startup {
my ($self) = @_;
+ $self->config(
+ hypnotoad => {
+ accepts => $ENV{DBFAKEDISPLAY_ACCEPTS} // 100,
+ clients => $ENV{DBFAKEDISPLAY_CLIENTS} // 10,
+ listen => [ $ENV{DBFAKEDISPLAY_LISTEN} // 'http://*:8092' ],
+ pid_file => $ENV{DBFAKEDISPLAY_PID_FILE}
+ // '/tmp/db-fakedisplay.pid',
+ spare => $ENV{DBFAKEDISPLAY_SPARE} // 2,
+ workers => $ENV{DBFAKEDISPLAY_WORKERS} // 2,
+ },
+ version => $ENV{DBFAKEDISPLAY_VERSION} // qx{git describe --dirty} // '???',
+ );
+
+ chomp $self->config->{version};
+
$self->hook(
before_dispatch => sub {
my ($self) = @_;
@@ -118,7 +129,7 @@ sub startup {
realtime_cache => $self->app->cache_iris_rt,
root_url => $self->url_for('/')->to_abs,
user_agent => $self->ua,
- version => $VERSION,
+ version => $self->config->{version},
);
}
);
@@ -132,7 +143,7 @@ sub startup {
realtime_cache => $self->app->cache_iris_rt,
root_url => $self->url_for('/')->to_abs,
user_agent => $self->ua,
- version => $VERSION,
+ version => $self->config->{version},
);
}
);
@@ -146,7 +157,7 @@ sub startup {
realtime_cache => $self->app->cache_iris_rt,
root_url => $self->url_for('/')->to_abs,
user_agent => $self->ua,
- version => $VERSION,
+ version => $self->config->{version},
);
}
);
@@ -211,7 +222,7 @@ sub startup {
$json = $self->render_to_string(
json => {
api_version => $api_version,
- version => $VERSION,
+ version => $self->config->{version},
error => $errstr,
}
);
@@ -226,7 +237,7 @@ sub startup {
$json = $self->render_to_string(
json => {
api_version => $api_version,
- version => $VERSION,
+ version => $self->config->{version},
error => 'ambiguous station code/name',
candidates => \@candidates,
}
@@ -236,7 +247,7 @@ sub startup {
$json = $self->render_to_string(
json => {
api_version => $api_version,
- version => $VERSION,
+ version => $self->config->{version},
error =>
( $errstr // "Got no results for '$station'" )
}
@@ -419,18 +430,6 @@ sub startup {
$r->get('/multi/*station')->to('stationboard#handle_request');
$r->get('/*station')->to('stationboard#handle_request');
- $self->config(
- hypnotoad => {
- accepts => $ENV{DBFAKEDISPLAY_ACCEPTS} // 100,
- clients => $ENV{DBFAKEDISPLAY_CLIENTS} // 10,
- listen => [ $ENV{DBFAKEDISPLAY_LISTEN} // 'http://*:8092' ],
- pid_file => $ENV{DBFAKEDISPLAY_PID_FILE}
- // '/tmp/db-fakedisplay.pid',
- spare => $ENV{DBFAKEDISPLAY_SPARE} // 2,
- workers => $ENV{DBFAKEDISPLAY_WORKERS} // 2,
- },
- );
-
$self->types->type( json => 'application/json; charset=utf-8' );
}