If you reached here you probably know Rad, but if you don't, please take a quick look on App::Rad, it is the basis for this plugin, that helps you
to make daemons very quickly.
Let us show you the first test daemon :
use App::Rad qw/Daemonize/;
App::Rad->run;
sub setup {
my $c = shift;
$c->daemonize(\&test, use_cmd_args => 1, stderr_logfile => "./test_err.log", stdout_logfile => "./test_out.log")
}
sub test {
while(sleep 1){
print "OUT: ", $count++, $/;
print { STDERR } "ERR: ", $count, $/;
warn "WARN: ", $count++, $/;
}
}
That's it!! We have our first example
As you see, you have to care with the infinite repetition structure on your sub, it's just write the sub and daemonize it.