NAME
Beekeeper::WorkerPool::Daemon - Daemonize processes
VERSION
Version 0.07
SYNOPSIS
package MyDaemon;
use base 'Beekeeper::WorkerPool::Daemon';
sub main {
my $self = shift;
my $quit = 0;
$SIG{'TERM'} = sub { $quit = 1 };
$SIG{'INT'} = sub { $quit = 1 };
while (!$quit) {
# Do something here...
sleep 1;
}
}
Then, the daemon can be executed with a script like this:
#!/usr/bin/perl -wT
use strict;
use warnings;
use MyDaemon;
$ENV{PATH} = '/bin'; # untaint
my $daemon = MyDaemon->new->run;
DESCRIPTION
This is a base module for creating daemons. It takes care of daemonization tasks commonly found in init.d scripts: forking, redirecting output, writing pid files, start/stop/restart control commands, etc.
It is used by the command line tool bkpr
to daemonize itself.
AUTHOR
José Micó, jose.mico@gmail.com
COPYRIGHT AND LICENSE
Copyright 2015-2021 José Micó.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language itself.
This software is distributed in the hope that it will be useful, but it is provided “as is” and without any express or implied warranties. For details, see the full text of the license in the file LICENSE.