-#!/usr/bin/perl
-
use strict;
use warnings;
-use Test::More 'no_plan';
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
use Test::Moose;
use File::Temp qw(tempdir);
use File::Spec::Functions;
BEGIN {
use_ok('MooseX::Daemonize::Core');
- use_ok('MooseX::Daemonize::Pid');
+ use_ok('MooseX::Daemonize::Pid');
}
use constant DEBUG => 0;
{
package MyFooDaemon;
use Moose;
-
+
with 'MooseX::Daemonize::Core';
-
+
has 'daemon_pid' => (is => 'rw', isa => 'MooseX::Daemonize::Pid');
-
+
# capture the PID from the fork
around 'daemon_fork' => sub {
my $next = shift;
);
}
};
-
+
sub start {
- my $self = shift;
+ my $self = shift;
# tell it to ignore zombies ...
- $self->daemonize(
- ignore_zombies => 1,
- no_double_fork => 1,
- );
+ $self->ignore_zombies( 1 );
+ $self->no_double_fork( 1 );
+ $self->daemonize;
return unless $self->is_daemon;
# change to our local dir
# so that we can debug easier
chdir $dir;
# make it easy to find with ps
$0 = 'test-app';
- $SIG{INT} = sub {
- print "Got INT! Oh Noes!";
+ $SIG{INT} = sub {
+ print "Got INT! Oh Noes!";
exit;
- };
+ };
while (1) {
- print "Hello from $$\n";
- sleep(10);
+ print "Hello from $$\n";
+ sleep(10);
}
exit;
}
isa_ok($d, 'MyFooDaemon');
does_ok($d, 'MooseX::Daemonize::Core');
-lives_ok {
- $d->start;
-} '... successfully daemonized from (' . $$ . ')';
+is(
+ exception { $d->start },
+ undef,
+ '... successfully daemonized from (' . $$ . ')',
+);
my $p = $d->daemon_pid;
isa_ok($p, 'MooseX::Daemonize::Pid');
unlink $ENV{MX_DAEMON_STDOUT};
unlink $ENV{MX_DAEMON_STDERR};
+done_testing;