11 $SIG{TERM} = $SIG{INT} = sub {++$Loop::ending; Mojo::IOLoop->stop;};
15 # WebSocket weather service
16 websocket '/weather' => sub {
22 app->log->debug('WebSocket opened.');
23 dbg 'WebSocket opened' if isdbg 'chan';
26 # send historical data
27 $c->send($ld->{lasthour_h}) if exists $ld->{lasthour_h};
28 $c->send($ld->{lastmin_h}) if exists $ld->{lastmin_h};
31 $c->inactivity_timeout(3615);
37 dbg "websocket: text $msg" if isdbg 'chan';
41 dbg "websocket: json $msg" if isdbg 'chan';
46 $c->on(finish => sub {
47 my ($c, $code, $reason) = @_;
48 app->log->debug("WebSocket closed with status $code.");
49 dbg "websocket closed with status $code" if isdbg 'chan';
54 get '/' => {template => 'index'};
64 dbg "*** starting $0";