Proc::tored::Role::Running - add running state and signal handling to services
version 0.05
package Some::Thing; use Moo; with 'Proc::tored::Running'; sub run { my $self = shift; $self->start; while ($self->is_running) { do_stuff(...); } }
Classes consuming this role are provided with controls to "start" and "stop" voluntarily, along with a SIGTERM handler that is active while the class "is_running". If a SIGTERM is received via another process (e.g., by calling "stop_running_process" in Proc::tored::Manager), the class will voluntarily "stop" itself.
SIGTERM
A Guard used to ensure signal handlers are restored when the object is destroyed.
Returns true while the service is running in the current process.
Flags the current process as running. While running, handlers for SIGTERM, SIGINT, SIGPIPE, and SIGHUP are installed. After calling this method, "is_running" will return true.
SIGINT
SIGPIPE
SIGHUP
Flags the current process as not running and restores any previously configured signal handlers. Once this method has been called, "is_running" will return false.
Jeff Ober <jeffober@gmail.com>
This software is copyright (c) 2017 by Jeff Ober.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Proc::tored, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Proc::tored
CPAN shell
perl -MCPAN -e shell install Proc::tored
For more information on module installation, please visit the detailed CPAN module installation guide.