PHAB_FEED_POLL_SECONDS
PHAB_USER_POLL_SECONDS
PHAB_GROUP_POLL_SECONDS
+ PHAB_TIMEOUT
);
use constant PHAB_ATTACHMENT_PATTERN => qr/^phabricator-D(\d+)/;
use constant PHAB_FEED_POLL_SECONDS => $ENV{PHAB_FEED_POLL} // 5;
use constant PHAB_USER_POLL_SECONDS => $ENV{PHAB_USER_POLL} // 60;
use constant PHAB_GROUP_POLL_SECONDS => $ENV{PHAB_GROUP_POLL} // 300;
+use constant PHAB_TIMEOUT => $ENV{PHAB_TIMEOUT} // 60;
1;
use IO::Async::Timer::Periodic;
use IO::Async::Loop;
+use IO::Async::Signal;
use List::Util qw(first);
use List::MoreUtils qw(any uniq);
use Moo;
sub start {
my ($self) = @_;
+ my $sig_alarm = IO::Async::Signal->new(
+ name => 'ALRM',
+ on_receipt => sub {
+ FATAL("Timeout reached");
+ exit;
+ },
+ );
# Query for new revisions or changes
my $feed_timer = IO::Async::Timer::Periodic->new(
first_interval => 0,
on_tick => sub {
try {
with_writable_database {
+ alarm(PHAB_TIMEOUT);
$self->feed_query();
};
}
catch {
FATAL($_);
+ }
+ finally {
+ alarm(0);
+ Bugzilla->_cleanup();
};
- Bugzilla->_cleanup();
},
);
on_tick => sub {
try {
with_writable_database {
+ alarm(PHAB_TIMEOUT);
$self->user_query();
};
}
catch {
FATAL($_);
+ }
+ finally {
+ alarm(0);
+ Bugzilla->_cleanup();
};
- Bugzilla->_cleanup();
},
);
on_tick => sub {
try {
with_writable_database {
+ alarm(PHAB_TIMEOUT);
$self->group_query();
};
}
catch {
FATAL($_);
+ }
+ finally {
+ alarm(0);
+ Bugzilla->_cleanup();
};
- Bugzilla->_cleanup();
+
},
);
$loop->add($feed_timer);
$loop->add($user_timer);
$loop->add($group_timer);
+ $loop->add($sig_alarm);
$feed_timer->start;
$user_timer->start;
$group_timer->start;