9 our $json_filename = "/srv/analysis.sesse.net/www/analysis.json";
11 my $cv = AnyEvent->condvar;
14 my $inotify = Linux::Inotify2->new;
15 $inotify->watch($json_filename, IN_MODIFY, sub {
20 my $inotify_w = AnyEvent->io (
21 fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll }
23 my $wait = AnyEvent->timer (
25 cb => sub { $cv->send; },
28 # Yes, this is reinventing If-Modified-Since, but browsers are so incredibly
29 # unpredictable on this, so blargh.
31 if (defined($cgi->param('ims')) && $cgi->param('ims') ne '') {
32 $ims = $cgi->param('ims');
34 my $time = (stat($json_filename))[9];
36 # If we have something that's modified since IMS, send it out at once
42 # If not, wait, then send.
47 open my $fh, "<", $json_filename
48 or die "$json_filename: $!";
54 my $time = (stat($fh))[9];
57 print CGI->header(-type=>'text/json',
58 -x_remoteglot_last_modified=>$time,
59 -access_control_allow_origin=>'http://analysis.sesse.net',
60 -access_control_expose_headers=>'X-Remoteglot-Last-Modified',