<% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>

FS::Daemon::Preforking

NAME

FS::Daemon::Preforking - A preforking web server

SYNOPSIS

  use FS::Daemon::Preforking qw( freeside_init1 freeside_init2 daemon_run );

  my $me = 'mydaemon'; #keep unique among fs daemons, for logfiles etc.

  freeside_init1($me); #daemonize, drop root and connect to freeside

  #do setup tasks which should throw an error to the shell starting the daemon

  freeside_init2($me); #move logging to logfile and disassociate from terminal

  #do setup tasks which will warn/error to the log file, such as declining to
  # run if our config is not in place

  daemon_run(
    'port'           => 5454, #keep unique among fs daemons
    'handle_request' => \&handle_request,
  );

  sub handle_request {
    my $request = shift; #HTTP::Request object

    #... do your thing

    return $response; #HTTP::Response object

  }

AUTHOR

Based on http://www.perlmonks.org/?node_id=582781 by Justin Hawkins

and http://poe.perl.org/?POE_Cookbook/Web_Server_With_Forking

<% include ('/elements/footer.html' ) %>