summary refs log tree commit diff
path: root/lib/presque/worker/Role/Management.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/presque/worker/Role/Management.pm')
-rw-r--r--lib/presque/worker/Role/Management.pm32
1 files changed, 8 insertions, 24 deletions
diff --git a/lib/presque/worker/Role/Management.pm b/lib/presque/worker/Role/Management.pm
index cdfcd6d..cceea4e 100644
--- a/lib/presque/worker/Role/Management.pm
+++ b/lib/presque/worker/Role/Management.pm
@@ -7,47 +7,31 @@ has shut_down => (is => 'rw', isa => 'Bool', default => 0,);
 before start => sub {
     my $self = shift;
     $self->rest_register_worker;
+    $SIG{INT}  = sub { $self->_shutdown };
+    $SIG{TERM} = sub { $self->_shutdown };
+    $SIG{QUIT} = sub { $self->_graceful_shutdown };
+    $SIG{USR1} = sub { $self->_kill_child };
+    $SIG{CHLD} = 'IGNORE';
 };
 
-after start => sub {
-    my $self = shift;
-    $self->rest_unregister_worker;
-};
-
-before start => sub {
-    my $self = shift;
-    $SIG{'INT'}  = sub { $self->_shutdown };
-    $SIG{'TERM'} = sub { $self->_shutdown };
-    $SIG{'QUIT'} = sub { $self->_graceful_shutdown };
-    $SIG{'USR1'} = sub { $self->_kill_child };
-};
+after start              => sub { (shift)->rest_unregister_worker; };
+after _graceful_shutdown => sub { (shift)->rest_unregister_worker; };
+after _shutdown          => sub { (shift)->rest_unregister_worker; };
 
 sub _shutdown {
     my $self = shift;
-    $self->logger->log(
-        level   => 'info',
-        message => 'worker ' . $self->worker_id . ' shuting down'
-    );
     $self->shut_down(1);
     $self->_kill_child();
 }
 
 sub _graceful_shutdown {
     my $self = shift;
-    $self->logger->log(
-        level   => 'info',
-        message => 'worker ' . $self->worker_id . ' kill child'
-    );
     $self->shut_down(1);
     $self->_kill_child();
 }
 
 sub _kill_child {
     my $self = shift;
-    $self->logger->log(
-        level   => 'info',
-        message => 'worker ' . $self->worker_id . ' shuting down gracefuly'
-    );
 }
 
 1;