7 use File::Spec::Functions;
9 use Test::More no_plan => 1;
14 use_ok('MooseX::Daemonize::Core');
18 my $PIDFILE = catfile($CWD, 'test-app.pid');
19 $ENV{MX_DAEMON_STDOUT} = catfile($CWD, 'Out.txt');
20 $ENV{MX_DAEMON_STDERR} = catfile($CWD, 'Err.txt');
26 with 'MooseX::Daemonize::Core',
27 'MooseX::Daemonize::WithPidFile';
30 MooseX::Daemonize::Pid::File->new( file => $PIDFILE )
37 return unless $self->is_daemon;
39 $self->pidfile->write;
41 # make it easy to find with ps
44 print "Got INT! Oh Noes!";
45 $self->pidfile->remove;
49 print "Hello from $$\n";
56 my $d = MyFooDaemon->new( pidfile => $PIDFILE );
57 isa_ok($d, 'MyFooDaemon');
58 does_ok($d, 'MooseX::Daemonize::Core');
59 does_ok($d, 'MooseX::Daemonize::WithPidFile');
61 ok($d->has_pidfile, '... we have a pidfile value');
65 isa_ok($p, 'MooseX::Daemonize::Pid::File');
69 ok(!(-e $PIDFILE), '... the PID file does not exist yet');
73 } '... successfully daemonized from (' . $$ . ')';
76 isa_ok($p, 'MooseX::Daemonize::Pid::File');
81 ok($p->does_file_exist, '... the PID file exists');
82 ok($p->is_running, '... the daemon process is running (' . $p->pid . ')');
87 diag `ps -x | grep test-app`;
95 diag `ps -x | grep test-app`;
97 ok(!$p->is_running, '... the daemon process is no longer running (' . $p->pid . ')');
98 ok(!(-e $PIDFILE), '... the PID file has been removed');