Proc::tored::Role::Running
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 (by calling "stop_running_process"), 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.
Issues a SIGTERM to the active process. Returns 0 immediately if the pid file does not exist or is empty. Otherwise, polls the running process until the OS reports that it is no longer able to receive signals (with `kill(0, $pid)`).
Optional parameter $timeout may be specified in fractional seconds, causing stop_running_process to block up to (around) $timeout seconds waiting for the signaled process to exit.
$timeout
stop_running_process
Returns the pid of the completed process otherwise.
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.