fix version in pod
[gitmo/MooseX-Daemonize.git] / lib / MooseX / Daemonize.pm
index 5c627ba..d0c60c6 100644 (file)
@@ -2,8 +2,9 @@ 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';
+our $VERSION   = '0.15';
 
 with 'MooseX::Daemonize::WithPidFile',
      'MooseX::Getopt';
@@ -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 );
 }
@@ -304,7 +314,11 @@ MooseX::Daemonize - Role for daemonizing your Moose based application
 
 =head1 VERSION
 
-This document describes MooseX::Daemonize version 0.05
+This document describes MooseX::Daemonize version 0.15
+
+=head1 WARNING
+
+The maintainers of this module now recommend using L<Daemon::Control> instead.
 
 =head1 SYNOPSIS
 
@@ -559,7 +573,7 @@ L<http://rt.cpan.org>.
 
 =head1 SEE ALSO
 
-L<Proc::Daemon>, L<Daemon::Generic>
+L<Daemon::Control>, L<Proc::Daemon>, L<Daemon::Generic>
 
 =head1 AUTHORS