System::Daemon
Swiss-knife for daemonization
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);
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, new => Write pid to newpidfile=pidfile.".new", if newpidfile dissapears or changed during daemon life, switch back to pidfile Note that even without this option, if pidfile.".new" found during destruction pidfile.".new" moved to pidfile location. These tools are for grace restart.
Call it to become a daemon.
An exit wrapper, also, it performing cleanup before exit.
Performing cleanup. At now cleanup is just pid file removing.
Same as finish.
Returns System::Process object of daemon instance.
To install System::Daemon, copy and paste the appropriate command in to your terminal.
cpanm
cpanm System::Daemon
CPAN shell
perl -MCPAN -e shell install System::Daemon
For more information on module installation, please visit the detailed CPAN module installation guide.