Any-Daemon
view release on metacpan or search on metacpan
lib/Any/Daemon.pod view on Meta::CPAN
pid_file undef
user undef
workdir current working directory
=over 2
=item group => GID|GROUPNAME
Change to this group (when started as root)
=item pid_file => FILENAME
=item user => UID|USERNAME
Change to this user (when started as root) If you want to run your
daemon as root, then explicitly specify that with this option, to
avoid a warning.
=item workdir => DIRECTORY
Change DIRECTORY so temporary files and such are not written in the
random directory where the daemon got started.
If the directory does not exist yet, it will be created with mode 0700
when the daemon object is initialized. We only move to that directory
when the daemon is run. The working directory does not get cleaned when
the daemon stops.
=back
=back
=head2 Accessors
=over 4
=item $obj-E<gt>B<pidFilename>()
=item $obj-E<gt>B<workdir>()
[0.90] assigned working directory of the daemon in the file-system.
=back
=head2 Action
=over 4
=item $obj-E<gt>B<run>(%options)
The C<run> method gets the activity related parameters.
You specify either C<run_task>, for the function to be called by this
deamon itself, or C<child_task> when you wish to manage child tasks
which run the action.
[0.96] When you pass a method name, it will be called on this object.
This is very clean when you have extended this daemon class.
-Option --Default
background <true>
child_died 'childDied'
child_task undef
kill_childs 'killChilds'
max_childs 10
reconfigure 'reconfigDaemon'
run_task undef
=over 2
=item background => BOOLEAN
Run the managing daemon in the background. During testing, it is
prefered to run the daemon in the foreground, to be able to stop
the daemon with Crtl-C and to see errors directly on the screen
in stead of only in some syslog file.
=item child_died => CODE|METHOD
The C<child_died> routine handles dieing kids and the restart of new
ones. It gets two parameters: the maximum number of childs plus the
task to perform per kid.
=item child_task => CODE|METHOD
The CODE will be run for each child which is started, also when they
are started later on. If the task is not specified, only a warning is
produced. This may be useful when you start implementing the daemon:
you do not need to care about the task to perform yet.
The returned value of thise CODE is used as exit code of the child
process, where zero means 'ok'.
=item kill_childs => CODE|METHOD
The CODE terminates all running children, maybe to start new ones,
maybe to terminate the whole daemon.
=item max_childs => INTEGER
The maximum (is usual) number of childs to run.
=item reconfigure => CODE|METHOD
The CODE is run when a SIGHUP is received; signal 1 is used by most
daemons as trigger for reconfiguration.
=item run_task => CODE|METHOD
[0.96] The CODE which will be run by this process. This implies: no
managed children.
=back
=back
=head1 SEE ALSO
This module is part of Any-Daemon distribution version 0.96,
built on October 08, 2018. Website: F<http://perl.overmeer.net/CPAN/>
=head1 LICENSE
Copyrights 2011-2018 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://dev.perl.org/licenses/>
( run in 0.893 second using v1.01-cache-2.11-cpan-f56aa216473 )