Make consumer.pl trap SIGINT and SIGTERM, disconnect cleanly
Signed-off-by: Pedro Melo <melo@simplicidade.org>
This commit is contained in:
1 parent
cfa7a7b4a5
commit
b69bd4a19b
1 file changed
+5
-2
@@ -29,10 +29,13 @@ my $r = AnyEvent::NSQ::Reader->new(
|
||||
|
||||
message_cb => sub { $t++; $message_cb->(@_, $t) },
|
||||
|
||||
error_cb => sub { warn "$_[1]\n" if $verbose },
|
||||
disconnect_cb => sub { warn "Got disconnected after $t total messages... exiting...\n" if $verbose; $cv->send },
|
||||
error_cb => sub { warn "$_[1]\n" if $verbose },
|
||||
disconnect_cb => sub { warn "Disconnected after $t total messages... exiting...\n" if $verbose; $cv->send },
|
||||
);
|
||||
|
||||
my $term_sgn = AE::signal TERM => sub { $r->disconnect };
|
||||
my $int_sgn = AE::signal INT => sub { $r->disconnect };
|
||||
|
||||
$cv->recv;
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user