Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Restart functions now, and the PID files are removed on stop. This re…

…solves issue 6 and issue 9.
  • Loading branch information...
commit adde607cdf86a03e62589c8fbe9907dec6070c24 1 parent c6cac65
@symkat authored
View
7 lib/Daemon/Control.pm
@@ -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;
}
}
View
12 t/02_sleep_perl.t
@@ -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;
View
12 t/02_sleep_system.t
@@ -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;
View
2  t/bin/02_sleep_perl.pl
@@ -14,7 +14,7 @@
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',
View
3  t/bin/02_sleep_system.pl
@@ -14,7 +14,8 @@
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',
Please sign in to comment.
Something went wrong with that request. Please try again.