dist | ||
lib/Proc/Simple | ||
LICENSE | ||
Makefile.PL | ||
README.md |
NAME
Proc::Simple::Daemon - Provide a standard daemonised loop method
VERSION
version 1.0
SYNOPSIS
my $loop = Proc::Simple::Daemon->new;
my $vars->{'loop'} = $loop;
$loop->foreground(1)
if $vars->{'run_in_foreground'};
$loop->run( \&mycallback, $vars );
# This will be executed as a different process ID unless we are
# set for foreground
sub
mycallback
{
my $vars = shift;
# do stuff
$vars->{'loop'}->stop
if $vars->{'need_to_stop'};
return;
}
DESCRIPTION
Proc::Simple::Daemon is a module to provide a standard daemon framework with timed loop with a callback and parameter.
PROPERTIES
-
poll_period
Get or set the poll period in seconds. Defaults to 1 second. Sleep period is calculated based on when the run starts and when the next period would be. If the callback takes longer than a poll period then it does not sleep but recalculates the next wake time and runs the callback again.
METHODS
-
run
Run the loop. Initialise as a new daemon process if this is the first call and we are not running in the foreground.
-
stop
Signal the loop to terminate. Would normally be called from within callback routine or interrupt handler to allow clean unwrap from original caller.
COMPATIBILITY
Proc::Simple::Daemon
requiresClass::Accessorize
,Proc::PID::File
,File::Basename
andSys::Syslog
.
AUTHOR
Bernard Quatermass toolsmith@quatermass.co.uk
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Bernard Quatermass.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.