Proc::Application::Daemon - daemon class based on Proc::Application;
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();
daemon class based on Proc::Application;
A construtror, setup childs and childCount
Add mode (fork|single|prefork=[count]) and socket (domain=unix|inet|ssl:all_io::socket:: parameter) options
Handler for socket option. Create new socket and store it to $object->{socket}
Child for 'prefork=count' mode and setup preforkCount option
Return a client socket from $object->{socket}
Return a main daemon socket from $object->{socket}
You must return 'true' for end main loop
Call handler() method with $cliendSocket atrument, log the errors of execution and close client socket at exit
Real work method, get $this and $clientSocket argumentds.
Return a hash reference of childs with keys with pids
SIGCHLD processor. Get a child pid by waitpid() and delete it from childs()
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
Main loop. accept() the new connection, and fork (if fork more) and pass execution to mainHandler
Prefork processes if prefork mode, loop up for preforked childs count and call realMain()
Send TERM signal to all childs and call parent DESTROY()
for compatibility with Net::Daemon
To install Proc::Application, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Proc::Application
CPAN shell
perl -MCPAN -e shell install Proc::Application
For more information on module installation, please visit the detailed CPAN module installation guide.