withpidfile should write its pidfile :)
[gitmo/MooseX-Daemonize.git] / lib / MooseX / Daemonize / WithPidFile.pm
1 package MooseX::Daemonize::WithPidFile;
2 use strict;
3 use Moose::Role;
4
5 use MooseX::Daemonize::Pid::File;
6
7 our $VERSION = 0.01;
8
9 with 'MooseX::Daemonize::Core';
10
11 requires 'init_pidfile';
12
13 has pidfile => (
14     isa       => 'MooseX::Daemonize::Pid::File',
15     is        => 'rw',
16     lazy      => 1,
17     required  => 1,
18     coerce    => 1,
19     predicate => 'has_pidfile',
20     builder   => 'init_pidfile',
21 );
22
23 after 'daemonize' => sub {
24     my $self = shift;
25     # NOTE:
26     # make sure that we do not have 
27     # any bad PID values stashed around
28     # - SL
29     $self->pidfile->clear_pid;
30     $self->pidfile->write if $self->is_daemon;
31 };
32
33 1;
34
35 __END__
36
37 =pod
38
39 =cut