POE::Component::Daemon

Handles all the housework for a daemon
Download

POE::Component::Daemon Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Philip Gwyn
  • Publisher web site:
  • http://search.cpan.org/~gwyn/

POE::Component::Daemon Tags


POE::Component::Daemon Description

Handles all the housework for a daemon Dealing with all the little details of a forking daemon can be annoying and hard. POE::Component::Daemon encapsulates all the details into one place and (hopefully) gets them right.POE::Component::Daemon is a Perl module that will deal with all the annoying details of creating and maintaining daemon processes. It can detach from the console, handle pre-forking pools or post-forking (ie, fork on each request). It will also redirect STDERR to a log file if asked.POE::Component::Daemon also babysits child processes, handling their CHLD. POE::Component::Daemon can also makes sure requests don't take to long. If they do, it will try to get rid of them. See "BABYSITING" below.POE::Component::Daemon does not handle listening on sockets. That is up to your code.Like all of POE, POE::Component::Daemon works cooperatively. It is up your code to tell POE::Component::Daemon when it is time to fork, block incoming requests when approriate and so on.Sub-processes are maintained with the help of a scoreboard. In some situations, your code will have to update it's status in scoreboard with the "update_status" method.SYNOPSIS use POE::Component::Daemon; POE::Component::Daemon->spawn(detach=>1, max_children=>3); # Create a session that uses SocketFactory POE::Session->create( inline_states=>{ _start=>sub { # catch this message from Daemon session $kernel->sig('daemon_child'=>'request'); # create a POE::Wheel::SocketFactory or whatever # ..... }, # socketfactory got a connection handle it here accept=>sub { # tell Daemon session about this Daemon->update_status('req', $info); }, ############### # we are now the child process (via the sig() in _start request=>sub { my($heap, $info)=@_; # $info was passed here from accept accept # create POE::Wheel::ReadWrite .... # tell Daemon session that this request will take a long time Daemon->update_status('long'); }, ############### # The request is finished finished=>sub { return unless $heap->{done}; # tell Deamon session that this request is done $poe_kernel->post(Daemon=>'update_status', 'done'); }, }); Requirements: · Perl


POE::Component::Daemon Related Software