Restart functions now, and the PID files are removed on stop. This resolves issue 6 and issue 9.
This commit is contained in:
parent
c6cac65c09
commit
adde607cdf
5 changed files with 30 additions and 6 deletions
|
@ -230,11 +230,12 @@ sub do_stop {
|
|||
exit 1;
|
||||
}
|
||||
$self->pretty_print( "Stopped" );
|
||||
exit 0;
|
||||
} else {
|
||||
$self->pretty_print( "Not Running", "red" );
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# Clean up the PID file on stop.
|
||||
unlink($self->pid_file) if $self->pid_file;
|
||||
}
|
||||
|
||||
sub do_restart {
|
||||
|
@ -253,10 +254,8 @@ sub do_status {
|
|||
|
||||
if ( $self->pid && $self->pid_running ) {
|
||||
$self->pretty_print( "Running" );
|
||||
exit 0;
|
||||
} else {
|
||||
$self->pretty_print( "Not Running", "red" );
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,4 +38,16 @@ sleep 10;
|
|||
ok $out = get_command_output( "perl -I$ilib $file status" ), "Get status of perl daemon.";
|
||||
ok $out =~ /Not Running/;
|
||||
|
||||
# Testing restart.
|
||||
ok $out = get_command_output( "perl -I$ilib $file start" ), "Started system daemon";
|
||||
ok $out =~ /Started/, "Daemon started for restarting.";
|
||||
ok $out = get_command_output( "perl -I$ilib $file status" ), "Get status of system daemon.";
|
||||
ok $out =~ /Running/, "Daemon running for restarting.";
|
||||
ok $out = get_command_output( "perl -I$ilib $file restart" ), "Get status of system daemon.";
|
||||
ok $out =~ /stopped.*started/si, "Daemon restarted.";
|
||||
ok $out = get_command_output( "perl -I$ilib $file status" ), "Get status of system daemon.";
|
||||
ok $out =~ /Running/, "Daemon running after restart.";
|
||||
ok $out = get_command_output( "perl -I$ilib $file stop" ), "Get status of system daemon.";
|
||||
ok $out =~ /Stopped/, "Daemon stopped after restart.";
|
||||
|
||||
done_testing;
|
||||
|
|
|
@ -38,4 +38,16 @@ sleep 10;
|
|||
ok $out = get_command_output( "perl -I$ilib $file status" ), "Get status of system daemon.";
|
||||
ok $out =~ /Not Running/;
|
||||
|
||||
# Testing restart.
|
||||
ok $out = get_command_output( "perl -I$ilib $file start" ), "Started system daemon";
|
||||
ok $out =~ /Started/, "Daemon started for restarting";
|
||||
ok $out = get_command_output( "perl -I$ilib $file status" ), "Get status of system daemon.";
|
||||
ok $out =~ /Running/, "Daemon running for restarting.";
|
||||
ok $out = get_command_output( "perl -I$ilib $file restart" ), "Get status of system daemon.";
|
||||
ok $out =~ /stopped.*started/si, "Daemon restarted.";
|
||||
ok $out = get_command_output( "perl -I$ilib $file status" ), "Get status of system daemon.";
|
||||
ok $out =~ /Running/, "Daemon running after restart.";
|
||||
ok $out = get_command_output( "perl -I$ilib $file stop" ), "Get status of system daemon.";
|
||||
ok $out =~ /Stopped/, "Daemon stopped after restart.";
|
||||
|
||||
done_testing;
|
||||
|
|
|
@ -14,7 +14,7 @@ Daemon::Control->new({
|
|||
program => sub { sleep $_[1] },
|
||||
program_args => [ 10 ],
|
||||
|
||||
pid_file => '/dev/null', # I don't want to leave tmp files for testing.
|
||||
pid_file => 'pid_tmp',
|
||||
stderr_file => '/dev/null',
|
||||
stdout_file => '/dev/null',
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ Daemon::Control->new({
|
|||
program => 'sleep',
|
||||
program_args => [ 10 ],
|
||||
|
||||
pid_file => '/dev/null', # I don't want to leave tmp files for testing.
|
||||
pid_file => 'pid_tmp',
|
||||
|
||||
stderr_file => '/dev/null',
|
||||
stdout_file => '/dev/null',
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue