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