Proc::Daemontools::Service - services that play nicely with daemontools
0.02
package Foo::Service; use base qw(Proc::Daemontools::Service); sub svc_up { ... } # In other code... my $serv = Foo::Service->new; $serv->run;
See the daemontools page, at http://cr.yp.to/daemontools.html, and particularly the svc page, at http://cr.yp.to/daemontools/svc.html.
new
Takes no arguments (yet).
run
Install signal handlers and call svc_run, which may continue indefinitely.
svc_run
If svc_run ever finishes, calls exit.
exit
$serv->exit($exit_status);
Exit, calling svc_exit first if it exists. Default signal handlers call this.
svc_exit
install_handlers
Install signal handlers to queue signals for processing by svc_* methods, below.
svc_*
NOTE: signal handlers are global. This means that two instances of Proc::Daemontools::Service will fight with each other. Don't do that.
Called by run. Your main program body should be here.
Called by exit. Any cleanup should be here. (optional)
Subclasses should define their own copy of each of these methods. They will be called by Proc::Daemontools::Service as signals are caught.
Names are taken from the full names of svc options.
When called, these methods will be passed a hashref indicating state.
the name of the signal (e.g. TERM)
the number of the signal (e.g. 15)
svc_hangup
svc_alarm
svc_interrupt
svc_terminate
Uncaught signals will cause your program to exit. If your package defines a svc_exit method, it will be called before exiting (see "exit").
The exit value will be the number of the signal that caused program exit.
svc_default
Override this method to provide your own default for the signals listed above.
KILL
STOP
CONT
Technically CONT isn't uncatchable; however, given that you can't catch STOP, you probably don't want to catch CONT either.
Hans Dieter Pearcey, <hdp@cpan.org>
<hdp@cpan.org>
Please report any bugs or feature requests to bug-proc-daemontools-service@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Proc-Daemontools-Service. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-proc-daemontools-service@rt.cpan.org
Copyright 2006 Hans Dieter Pearcey, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Proc::Daemontools::Service, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Proc::Daemontools::Service
CPAN shell
perl -MCPAN -e shell install Proc::Daemontools::Service
For more information on module installation, please visit the detailed CPAN module installation guide.