7 use File::Spec::Functions;
9 use Test::More no_plan => 1;
14 use_ok('MooseX::Daemonize::Core');
15 use_ok('MooseX::Daemonize::Pid');
19 $ENV{MX_DAEMON_STDOUT} = catfile($CWD, 'Out.txt');
20 $ENV{MX_DAEMON_STDERR} = catfile($CWD, 'Err.txt');
26 with 'MooseX::Daemonize::Core';
28 has 'daemon_pid' => (is => 'rw', isa => 'MooseX::Daemonize::Pid');
30 # capture the PID from the fork
31 around 'daemon_fork' => sub {
34 if (my $pid = $self->$next(@_)) {
36 MooseX::Daemonize::Pid->new(pid => $pid)
43 # tell it to ignore zombies ...
48 return unless $self->is_daemon;
49 # change to our local dir
50 # so that we can debug easier
52 # make it easy to find with ps
55 print "Got INT! Oh Noes!";
59 print "Hello from $$\n";
66 my $d = MyFooDaemon->new;
67 isa_ok($d, 'MyFooDaemon');
68 does_ok($d, 'MooseX::Daemonize::Core');
72 } '... successfully daemonized from (' . $$ . ')';
74 my $p = $d->daemon_pid;
75 isa_ok($p, 'MooseX::Daemonize::Pid');
77 ok($p->is_running, '... the daemon process is running (' . $p->pid . ')');
82 diag `ps -x | grep test-app`;
90 diag `ps -x | grep test-app`;
92 ok(!$p->is_running, '... the daemon process is no longer running (' . $p->pid . ')');