NAME

System::Daemon

DESCRIPTION

Swiss-knife for daemonization

SYNOPSIS

See little example:

use System::Daemon;

$0 = 'my_daemon_process_name';

my $daemon = System::Daemon->new(
    user            =>  'username',
    group           =>  'groupname',
    pidfile         =>  'path/to/pidfile',
    daemonize       =>  0,
);
$daemon->daemonize();

your_cool_code();

$daemon->exit(0);

METHODS

new(%params)

Constructor, returns System::Daemon object. Available parameters:

user            =>  desired_username,
group           =>  desired_groupname,
pidfile         =>  '/path/to/pidfile',
procname        =>  process name for ps output,
mkdir           =>  tries to create directory for pid files,
daemonize       =>  if not true, will not daemonize, for debug reasons,
procname        =>  after daemonize $0 will be updated to desired name,
daemonize

Call it to become a daemon.

exit($exit_code)

An exit wrapper, also, it performing cleanup before exit.

finish

Performing cleanup. At now cleanup is just pid file removing.

cleanup

Same as finish.

process_object

Returns System::Process object of daemon instance.