NAME

Proc::Daemontools::Service - services that play nicely with daemontools

VERSION

 0.02

SYNOPSIS

  package Foo::Service;
  use base qw(Proc::Daemontools::Service);

  sub svc_up { ... }

  # In other code...

  my $serv = Foo::Service->new;
  $serv->run;

DESCRIPTION

See the daemontools page, at http://cr.yp.to/daemontools.html, and particularly the svc page, at http://cr.yp.to/daemontools/svc.html.

METHODS

new

Takes no arguments (yet).

run

Install signal handlers and call svc_run, which may continue indefinitely.

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.

install_handlers

Install signal handlers to queue signals for processing by svc_* methods, below.

NOTE: signal handlers are global. This means that two instances of Proc::Daemontools::Service will fight with each other. Don't do that.

HOOKS

svc_run

Called by run. Your main program body should be here.

svc_exit

Called by exit. Any cleanup should be here. (optional)

SIGNALS

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.

signal

the name of the signal (e.g. TERM)

signum

the number of the signal (e.g. 15)

svc_hangup

svc_alarm

svc_interrupt

svc_terminate

DEFAULT HANDLERS

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.

UNCATCHABLE SIGNALS

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.

AUTHOR

Hans Dieter Pearcey, <hdp@cpan.org>

BUGS

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.

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

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.