Daemon-Generic
view release on metacpan or search on metacpan
Normal behavior: exit. Only referenced by
"gd_setup_signals()".
gd_kill_groups()
Return true if gd_kill should kill process groups ($pid)
instead of just the one daemon ($pid). Default is false.
gd_kill($pid) Used by the "stop" and "restart" commands to get rid of
the old daemon. Normal behavior: send a SIGINT. Check to
see if process $pid has died. If it has not, keep
checking and if it's still alive. After
$Daemon::Generic::force_quit_delay seconds, send a
SIGTERM. Keep checking. After another
$Daemon::Generic::force_quit_delay seconds, send a
SIGKILL (-9). Keep checking. After
"$Daemon::Generic::force_quit_delay * 4" seconds or 60
seconds (whichever is smaller), give up and exit(1).
gd_install Installs the daemon so that it runs automatically at next
reboot. Currently done with a symlink to $0 and
"/usr/sbin/update-rc.d". Please send patches for other
lib/Daemon/Generic.pod view on Meta::CPAN
Return true if gd_kill should kill process groups ($pid) instead of just
the one daemon ($pid). Default is false.
=item gd_kill($pid)
Used by the C<stop> and C<restart> commands to get rid of
the old daemon.
Normal behavior: send a SIGINT.
Check to see if process C<$pid> has died. If it has not, keep checking
and if it's still alive. After
C<$Daemon::Generic::force_quit_delay> seconds,
send a SIGTERM. Keep checking. After another
C<$Daemon::Generic::force_quit_delay> seconds,
send a SIGKILL (-9). Keep checking. After
C<$Daemon::Generic::force_quit_delay * 4> seconds or 60 seconds
(whichever is smaller), give up and exit(1).
=item gd_install
Installs the daemon so that it runs automatically at next
lib/Daemon/Generic/While1.pm view on Meta::CPAN
$self->{gd_sighup} = time;
};
my $child;
$SIG{INT} = sub {
$self->{gd_sigint} = time;
#
# We'll be getting a SIGTERM in a bit if we're not dead, so let's use it.
#
$SIG{TERM} = sub {
$self->gd_quit_event();
kill(15, $child) if $child; # if we're still alive, let's stay that way
};
};
}
sub gd_sleep
{
my ($self, $period) = @_;
croak "Sleep period must be defined" unless defined $period;
my $hires;
if ($period*1000 != int($period*1000)) {
append_file("$tmp/config", "COUNTER=$tmp/counter2");
like(run('reload'), qr/reconfiguration/, "reconfig message");
expect { -s "$tmp/counter2" };
my $counter2 = read_file("$tmp/pid");
chomp($counter2);
like($counter2, qr/^\d+$/, "counter2");
ok(kill(0,$pid), "process $pid is alive - $name");
my $check = run('check');
like($check, qr/Configuration looks okay/, "config ok - $name");
like($check, qr/running - pid \d+/, "running");
like(run('stop'), qr/Killing/, "kill message");
ok(!kill(0,$pid), "process is dead - $name");
my $check2 = run('check');
( run in 1.041 second using v1.01-cache-2.11-cpan-39bf76dae61 )