]> git.sesse.net Git - remoteglot/blobdiff - remoteglot.pl
Add a separate script for counting viewers from Varnish logs.
[remoteglot] / remoteglot.pl
index b128e29735b99e7a520d1d31ecec61db0d7cfe40..8cfb0be553049e74ba03fef87597a76bc02838b7 100755 (executable)
@@ -28,8 +28,8 @@ use warnings;
 no warnings qw(once);
 
 # Program starts here
-$SIG{ALRM} = sub { output(); };
 my $latest_update = undef;
+my $output_timer = undef;
 my $http_timer = undef;
 my $tb_retry_timer = undef;
 my %tb_cache = ();
@@ -478,7 +478,8 @@ sub output {
        # Don't update too often.
        my $age = Time::HiRes::tv_interval($latest_update);
        if ($age < $remoteglotconf::update_max_interval) {
-               Time::HiRes::alarm($remoteglotconf::update_max_interval + 0.01 - $age);
+               my $wait = $remoteglotconf::update_max_interval + 0.01 - $age;
+               $output_timer = AnyEvent->timer(after => $wait, cb => \&output);
                return;
        }