NAME
Daemon::Daemonize - A daemonizer
VERSION
Version 0.001
SYNOPSIS
use Daemon::Daemonize
Daemon::Daemonize->daemonize( %options, run => sub {
# Daemon code in here...
} )
# Do some non-daemon stuff here...
You can also use it in the traditional way, daemonizing the current
process:
Daemon::Daemonize->daemonize( %options )
# Daemon code in here...
...and use it to check up on your daemon:
# In your daemon
Daemon::Daemonize->write_pidfile( $pidfile )
$SIG{INT} = sub { Daemon::Daemonize->delete_pidfile( $pidfile ) }
... Elsewhere ...
# Return the pid from $pidfile if it contains a pid AND
# the process is running (even if you don't own it), 0 otherwise
my $pid = Daemon::Daemonize->check_pidfile( $pidfile )
# Return the pid from $pidfile, or undef if the
# file doesn't exist, is unreadable, etc.
# This will return the pid regardless of if the process is running
my $pid = Daemon::Daemonize->read_pidfile( $pidfile )
DESCRIPTION
Daemon::Daemonize is a toolbox for both daemonizing processes & checking
up on those processes. It takes inspiration from
After daemonizing, run the given code and then exit successfully
Daemon::Daemonize->read_pidfile( $pidfile )
Return the pid from $pidfile. Return undef if the file doesn't exist, is
unreadable, etc. This will return the pid regardless of if the process
is running
For an alternative, see "check_pidfile"
Daemon::Daemonize->write_pidfile( $pidfile, [ $pid ] )
Write the given pid to $pidfile, creating/overwriting any existing file.
The second argument is optional, and will default to $$ (the current
process number)
Daemon::Daemonize->delete_pidfile( $pidfile )
Unconditionally delete (unlink) $pidfile
Daemon::Daemonize->check_pidfile( $pidfile )
Return the pid from $pidfile if it contains a pid AND the process is
running (even if you don't own it), and 0 otherwise
This method will always return a number
SEE ALSO
MooseX::Daemonize
Proc::Daemon
Net::Server::Daemonize
AUTHOR
Robert Krimen, ""
BUGS
Please report any bugs or feature requests to "bug-daemon-daemonize at
rt.cpan.org", or through the web interface at
. I
will be notified, and then you'll automatically be notified of progress
on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Daemon::Daemonize
You can also look for information at:
* RT: CPAN's request tracker
* AnnoCPAN: Annotated CPAN documentation
* CPAN Ratings
* Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2009 Robert Krimen.
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.