Working::Daemon - Perl extension for turning your script inta daemon.
use Working::Daemon; our $VERSION = 0.45; my $daemon = Working::Daemon->new(); $daemon->name("testdaemon"); $daemon->standard("bool" => 1 => "Test if you can set bools", "integer=i" => 2323 => "Integer settings", "string=s" => string => "String setting", "multi=s%" => undef() => "Multiset variable");
use Working::Daemon; our $VERSION = 0.45; my $daemon = Working::Daemon->new(); $daemon->name("testdaemon"); $daemon->user("foo"); $daemon->parse_options("myoption" => "sets myoption!"); $daemon->do_action; # only the worker continues to from here $self->change_root; $self->drop_privs; # your app codefrom here
This is a modular Daemon wrapper. It handles forking, master session, chroot pidfiles, and command line parsing.
While it isn't perfect yet, it works better than any existing on CPAN. Notably it doesn't force itself on you unconditionally.
The commandline parsing uses Getopt::Long
It also supports start,stop,status and restart. So you can symlink your daemon directly into init.d
Artur Bergman, <firstname.lastname@example.org@>
Copyright (C) 2008 by Artur Bergman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.