use strict; # because Kwalitee is pedantic
use Moose::Role;
use MooseX::Types::Path::Class;
+use File::Path qw(make_path);
our $VERSION = '0.13';
sub init_pidfile {
my $self = shift;
my $file = $self->pidbase . '/' . $self->progname . '.pid';
+
+ if ( !-d $self->pidbase ) {
+ make_path( $self->pidbase, { error => \my $err } );
+ if (@$err) {
+ confess sprintf( "Cannot create pidbase directory '%s': %s",
+ $self->pidbase, @$err );
+ }
+ }
+
confess "Cannot write to $file" unless (-e $file ? -w $file : -w $self->pidbase);
MooseX::Daemonize::Pid::File->new( file => $file );
}
}
my $app = FileMaker->new(
- pidbase => $dir,
+ pidbase => "$dir/subdir",
filename => $FILENAME,
);
isa_ok($app, 'FileMaker');
isa_ok($app->pidfile, 'MooseX::Daemonize::Pid::File');
-is($app->pidfile->file, catfile($dir, "filemaker.pid"), '... got the right PID file path');
+is($app->pidfile->file, catfile("$dir/subdir", "filemaker.pid"), '... got the right PID file path');
ok(not(-e $app->pidfile->file), '... our pidfile does not exist');
ok(!$app->status, '... the daemon is running');