X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FDaemonize.pm;h=4d21a262c7f8417ad1fa2aae8292b5001b314313;hb=92b4ca7e92855805646082226e3632d94f178861;hp=5c627bac6eb8670831adf583d419d09a02b964ef;hpb=05b96f4d04d93f2344602f7b3ef43da01c0a2794;p=gitmo%2FMooseX-Daemonize.git diff --git a/lib/MooseX/Daemonize.pm b/lib/MooseX/Daemonize.pm index 5c627ba..4d21a26 100644 --- a/lib/MooseX/Daemonize.pm +++ b/lib/MooseX/Daemonize.pm @@ -2,6 +2,7 @@ package MooseX::Daemonize; use strict; # because Kwalitee is pedantic use Moose::Role; use MooseX::Types::Path::Class; +use File::Path qw(make_path); our $VERSION = '0.13'; @@ -81,6 +82,15 @@ has exit_code => ( 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 ); } @@ -559,7 +569,7 @@ L. =head1 SEE ALSO -L, L +L, L, L =head1 AUTHORS