The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Proc::Application::Daemon - daemon class based on Proc::Application;

SYNOPSIS

 package Program;
 use Proc::Application::Daemon;
 use base qw(Proc::Application::Daemon);
 sub handler 
 {
     my ( $his, $clientSocket ) = @_;
     $this->socket->print ( 'Done' );
     $this->log->warning ( 'warning' );
     die "Error";
 }
 package main;
 Program->new->run();

DESCRIPTION

daemon class based on Proc::Application;

new

A construtror, setup childs and childCount

options

Add mode (fork|single|prefork=[count]) and socket (domain=unix|inet|ssl:all_io::socket:: parameter) options

processSocketCreate

Handler for socket option. Create new socket and store it to $object->{socket}

processModeParameter

Child for 'prefork=count' mode and setup preforkCount option

socket

Return a client socket from $object->{socket}

mainSocket

Return a main daemon socket from $object->{socket}

done

You must return 'true' for end main loop

mainHandler

Call handler() method with $cliendSocket atrument, log the errors of execution and close client socket at exit

handler

Real work method, get $this and $clientSocket argumentds.

childs

Return a hash reference of childs with keys with pids

processSigChild

SIGCHLD processor. Get a child pid by waitpid() and delete it from childs()

forkFunction

Get three code refs ( for run at parent, child and error fork sitiations ), fork process and execute parameters functions. Store pid of new process at childs(), exit(0) at child after execute of child function, log fork error and sleep(1) after fork error. funtions

threadFunction

realMain

Main loop. accept() the new connection, and fork (if fork more) and pass execution to mainHandler

main

Prefork processes if prefork mode, loop up for preforked childs count and call realMain()

DESTROY

Send TERM signal to all childs and call parent DESTROY()

Log Debug Error Fatal Run Options

for compatibility with Net::Daemon