1 package MooseX::Daemonize::WithPidFile;
2 use strict; # cause Perl::Critic errors are annoying
3 use MooseX::Getopt; # to load the Getopt metaclass
8 use MooseX::Daemonize::Pid::File;
10 with 'MooseX::Daemonize::Core';
12 requires 'init_pidfile';
16 # this should always be accessible
17 # from the command line IMO
19 metaclass => 'Getopt',
20 isa => 'MooseX::Daemonize::Pid::File',
24 predicate => 'has_pidfile',
25 builder => 'init_pidfile',
28 after 'daemonize' => sub {
31 # make sure that we do not have
32 # any bad PID values stashed around
34 $self->pidfile->clear_pid;
35 if ($self->is_daemon) {
36 $self->pidfile->write;
48 MooseX::Daemonize::WithPidFile - A Role with the core daemonization and pidfile management
55 with 'MooseX::Daemonize::WithPidFile';
60 $self->daemonize; # << this will write the pidfile for you
61 # return from the parent,...
62 return unless $self->is_daemon;
63 # but continue on in the child (daemon)
68 This is a slightly extended basic daemonization Role, it provides
69 Pidfile management along with the core daemonization features
70 found in L<MooseX::Daemonize::Core>.
76 =item I<pidfile (is => rw, isa => MooseX::Daemonize::Pid::File)>
78 This attribute holds the L<MooseX::Daemonize::Pid::File> object used
79 to manage the Pidfile. It will initialize the object using the
80 C<init_pidfile> method (which is required by this role).
84 =head1 REQUIRED METHODS
90 This method is used to build the I<pidfile> attribute's object. It should
91 return a L<MooseX::Daemonize::Pid::File> object.
95 This is a predicate method to tell you if your I<pidfile> attribute has
106 This adds an C<after> method modifier to the C<daemonize> method (from
107 L<MooseX::Daemonize::Core>) and handles writing your Pidfile for you.
111 The C<meta()> method from L<Class::MOP::Class>
117 L<Moose::Role>, L<MooseX::Getopt> and L<MooseX::Daemonize::Pid::File>
119 =head1 INCOMPATIBILITIES
123 =head1 BUGS AND LIMITATIONS
125 No bugs have been reported.
127 Please report any bugs or feature requests to
128 C<bug-acme-dahut-call@rt.cpan.org>, or through the web interface at
129 L<http://rt.cpan.org>.
133 Stevan Little C<< <stevan.little@iinteractive.com> >>
135 =head1 LICENCE AND COPYRIGHT
137 Copyright (c) 2007-2008, Chris Prather C<< <perigrin@cpan.org> >>. All rights
140 Portions heavily borrowed from L<Proc::Daemon> which is copyright Earl Hood.
142 This module is free software; you can redistribute it and/or
143 modify it under the same terms as Perl itself. See L<perlartistic>.
145 =head1 DISCLAIMER OF WARRANTY
147 BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
148 FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
149 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
150 PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
151 EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
152 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
153 ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
154 YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
155 NECESSARY SERVICING, REPAIR, OR CORRECTION.
157 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
158 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
159 REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
160 LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
161 OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
162 THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
163 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
164 FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
165 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF