| App::Framework::Extension::Daemon |
App::Framework::Daemon - Daemonize an application
use App::Framework qw/Daemon/ ;
App::Framework personality that provides a daemonized program (using Net::Server::Daemonize)
None
Create a new App::Framework::Daemon.
The %args are specified as they would be in the set method, for example:
'mmap_handler' => $mmap_handler
The full list of possible arguments are :
'fields' => Either ARRAY list of valid field names, or HASH of field names with default values
Initialises the object class variables.
Daemonize then run the application's app subroutine inside a loop.
=cut
sub daemon_run { my $this = shift ;
my $use_net=0; if ($use_net) {
print "Calling daemonize()...\n" ; ## Daemonize Net::Server::Daemonize::daemonize( $this->user, # User $this->group, # Group $this->pid, # Path to PID file - optional ); print "Calling application run...\n" ;
## call application run
$this->call_extend_fn('app_fn') ;
}
else
{
##my $pid = safe_fork();
print "Calling fork()...\n" ;
my $pid = fork;
unless( defined $pid ){
die "Couldn't fork: [$!]\n";
}
### parent process should do the pid file and exit if( $pid ){
print "Killing parent..\n" ;
$pid && exit(0);
### child process will continue on }else{
print "Calling application run...\n" ;
## call application run
$this->call_extend_fn('app_fn') ;
} }
}
# ============================================================================================ # PRIVATE METHODS # ============================================================================================
# ============================================================================================ # END OF PACKAGE
Setting the debug flag to level 1 prints out (to STDOUT) some debug messages, setting it to level 2 prints out more verbose messages.
Steve Price <sdprice at cpan.org>
None that I know of!
| App::Framework::Extension::Daemon |