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