with qw(MooseX::Daemonize);
has filename => ( isa => 'Str', is => 'ro' );
-
- after start => sub {
+
+ after start => sub {
my $self = shift;
if ($self->is_daemon) {
$self->create_file( $self->filename );
if (DEBUG) {
diag `ps $pid`;
- diag "Status is: " . $app->status_message;
+ diag "Status is: " . $app->status_message;
}
ok( -e $app->filename, "file exists" );
if (DEBUG) {
diag `ps $pid`;
- diag "Status is: " . $app->status_message;
+ diag "Status is: " . $app->status_message;
}
ok( $app->stop, '... app stopped' );
if (DEBUG) {
diag `ps $pid`;
- diag "Status is: " . $app->status_message;
+ diag "Status is: " . $app->status_message;
}
ok( not(-e $app->pidfile->file) , '... pidfile gone' );
after start => sub {
my ($self) = @_;
- $self->output_ok()
+ $self->output_ok()
if $self->is_daemon;
};
my $warnings = "";
{
- local $SIG{__WARN__} = sub { $warnings .= $_[0]; warn @_ };
- $app->stop( no_exit => 1 );
+ local $SIG{__WARN__} = sub { $warnings .= $_[0]; warn @_ };
+ $app->stop( no_exit => 1 );
}
is($warnings, "", "No warnings from stop");
);
is($f->file->slurp(chomp => 1), $f->pid, '... the PID in the file is correct');
-
+
ok($f->is_running, '... it is running too');
is(
is($f->file->slurp(chomp => 1), $f->pid, '... the PID in the file is correct');
is($f->pid, $$, '... the PID is our current process');
-
- ok($f->is_running, '... it is running too');
+
+ ok($f->is_running, '... it is running too');
is(
exception { $f->remove },
{
my $PID = 9999;
-
+
my $f = MooseX::Daemonize::Pid::File->new(
file => [ 't', 'baz.pid' ],
pid => $PID,
isa_ok($f, 'MooseX::Daemonize::Pid::File');
isa_ok($f->file, 'Path::Class::File');
-
+
is($f->pid, $PID, '... the PID is our made up PID');
is(
BEGIN {
- use_ok('MooseX::Daemonize::Core');
+ use_ok('MooseX::Daemonize::Core');
}
use constant DEBUG => 0;
{
package MyFooDaemon;
use Moose;
-
+
with 'MooseX::Daemonize::WithPidFile';
-
+
sub init_pidfile {
MooseX::Daemonize::Pid::File->new( file => $PIDFILE )
}
-
+
sub start {
my $self = shift;
-
- # this tests our bad PID
+
+ # this tests our bad PID
# cleanup functionality.
print "Our parent PID is " . $self->pidfile->pid . "\n" if ::DEBUG;
-
+
$self->daemonize;
return unless $self->is_daemon;
-
+
# make it easy to find with ps
$0 = 'test-app-2';
- $SIG{INT} = sub {
- print "Got INT! Oh Noes!";
+ $SIG{INT} = sub {
+ print "Got INT! Oh Noes!";
$self->pidfile->remove;
exit;
- };
+ };
while (1) {
- print "Hello from $$\n";
- sleep(10);
+ print "Hello from $$\n";
+ sleep(10);
}
exit;
}