7 use File::Spec::Functions;
9 use Test::More no_plan => 1;
14 use_ok('MooseX::Daemonize::Core');
17 use constant DEBUG => 0;
20 my $PIDFILE = catfile($CWD, 'test-app.pid');
21 $ENV{MX_DAEMON_STDOUT} = catfile($CWD, 'Out.txt');
22 $ENV{MX_DAEMON_STDERR} = catfile($CWD, 'Err.txt');
28 with 'MooseX::Daemonize::WithPidFile';
31 MooseX::Daemonize::Pid::File->new( file => $PIDFILE )
37 # this tests our bad PID
38 # cleanup functionality.
39 print "Our parent PID is " . $self->pidfile->pid . "\n";
42 return unless $self->is_daemon;
44 $self->pidfile->write;
46 # make it easy to find with ps
49 print "Got INT! Oh Noes!";
50 $self->pidfile->remove;
54 print "Hello from $$\n";
61 my $d = MyFooDaemon->new( pidfile => $PIDFILE );
62 isa_ok($d, 'MyFooDaemon');
63 does_ok($d, 'MooseX::Daemonize::Core');
64 does_ok($d, 'MooseX::Daemonize::WithPidFile');
66 ok($d->has_pidfile, '... we have a pidfile value');
70 isa_ok($p, 'MooseX::Daemonize::Pid::File');
74 ok(!(-e $PIDFILE), '... the PID file does not exist yet');
78 } '... successfully daemonized from (' . $$ . ')';
81 isa_ok($p, 'MooseX::Daemonize::Pid::File');
86 ok($p->does_file_exist, '... the PID file exists');
87 ok($p->is_running, '... the daemon process is running (' . $p->pid . ')');
93 diag `ps -x | grep test-app`;
98 diag "killed $pid" if DEBUG;
103 diag `ps -x | grep test-app`;
106 ok(!$p->is_running, '... the daemon process is no longer running (' . $p->pid . ')');
107 ok(!(-e $PIDFILE), '... the PID file has been removed');