);
has pidbase => (
- isa => 'Str',
- is => 'ro',
- lazy => 1,
- required => 1,
- default => sub { return '/var/run' },
+ isa => 'Str',
+ is => 'ro',
+
+ # required => 1,
+ lazy => 1,
+ default => sub { return '/var/run' },
);
has pidfile => (
if ( CORE::kill 0 => $pid ) {
croak "$prog already running ($pid).";
}
- carp "$prog not running but $pid exists. Perhaps it is stale?";
+ carp "$prog not running but found pid ($pid)."
+ . "Perhaps the pid file (@{ [$self->pidfile] }) is stale?";
return 1;
}
return 0;
$SIG{HUP} = sub { $self->handle_sighup };
}
-sub handle_sigint { $_[0]->stop }
-sub handle_sighup { return; }
+sub handle_sigint { $_[0]->stop; }
+sub handle_sighup { $_[0]->restart; }
sub kill {
my ( $self, $pid ) = @_;
+ return unless $pid;
unless ( CORE::kill 0 => $pid ) {
# warn "$pid already appears dead.";
}
CORE::kill( 2, $pid ); # Try SIGINT
- sleep(1) if CORE::kill( 0, $pid );
+ sleep(2) if CORE::kill( 0, $pid );
unless ( CORE::kill 0 => $pid or $!{EPERM} ) { # IF it is still running
CORE::kill( 15, $pid ); # try SIGTERM
- sleep(1) if CORE::kill( 0, $pid );
+ sleep(2) if CORE::kill( 0, $pid );
}
unless ( CORE::kill 0 => $pid or $!{EPERM} ) { # IF it is still running
CORE::kill( 9, $pid ); # finally try SIGKILL
- sleep(1) if CORE::kill( 0, $pid );
+ sleep(2) if CORE::kill( 0, $pid );
}
unless ( CORE::kill 0 => $pid or $!{EPERM} ) { # IF it is still running