NAME
Proc::tored::Role::Running - add running state and signal handling to services
VERSION
version 0.07
SYNOPSIS
package Some::Thing;
use Moo;
with 'Proc::tored::Running';
sub run {
my $self = shift;
$self->start;
while ($self->is_running) {
do_stuff(...);
}
}
DESCRIPTION
Classes consuming this role are provided with controls to "start" and "stop" voluntarily through the use of a touch file to signal the process to self-terminate.
ATTRIBUTES
term_file
Specifies a file path that will be used as a touch file to signal the process to self-terminate.
METHODS
is_running
Returns true while the service is running in the current process.
start
Flags the current process as running. After calling this method, "is_running" will return true.
stop
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.
signal
Signals the process to stop running by creating a touch file.
AUTHOR
Jeff Ober <jeffober@gmail.com>
COPYRIGHT AND LICENSE
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.