Acme-Spork

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

        - or updated the version in README
	- added "the" to the POD near plastic for good measure
	- make spork() return (instead of croak) if fork fails so you can handle the failure as need be
	- added child sig so zombies do not happen, we hope anyhoo ;p
        - slowed down to hopefully not miss the stupid stuff

0.0.4  Tue Sep 12 20:38:30 CDT 2006
    - added daemonize_without_close_on()
    - added local $SIG{'HUP'} until Proc::Daemon comes around
	- fixed 0.0.3 above :)
	- fixed daemonize() example use of Unix::Pid to properly do pid file after daemonize changes the pid
	
0.0.5  Wed Nov 15 17:51:02 2006
	- keeps $SIG{'CHLD'} if defined instead of using IGNORE
	- local()ize'd $SIG{'CHLD'}

0.0.6  	Tue Jan 16 23:54:01 2007
    - added @reopen_to

0.0.7  Wed Jan 17 09:52:55 2007
	- changed 0.0.6 to %reopen_stdfhs_to for clarity

lib/Acme/Spork.pm  view on Meta::CPAN


=head1 daemonize()

Since many daemons need to spork a child process when a request is received I've included a cheat function to daemonize your script execution.

Its simply a wrapper for Proc::Daemon::Init.

    use Acme::Spork qw(daemonize);

    # make sure we are the only one running:
    use Unix::Pid '/var/run/this.pid';

    # if so make me a daemon:
    daemonize();

    # and redo the pid_file with the new pid
    Unix::PID->new()->pid_file('/var/run/this.pid') 
        or die 'The PID in /var/run/this.pid is still running.'; 

    # and handle requests as a server:
    while(<$incoming_requests>) {
        my $req_pid = spork(\&handle_request($_));
        if($req_pid) {
            spork(\&log_request($_), $req_pid) 
                or warn "Could not spork log request $req_pid: $!";
        }
        else {

lib/Acme/Spork.pm  view on Meta::CPAN

If you set $SIG{CHLD} to 'IGNORE' all your $?'s will be -1 (i.e not what you might be expecting)

=head1 EXPORT

spork() is by default, daemonize() and daemonize_without_close_on() can be.

=head1 SEE ALSO

L<Proc::Daemon> is not used unless you call daemonize().

L<Unix::PID> is not used at all in this module except the daemonize() example. I figured if you were using this module you many be interested in it as well :)

=head1 ATTN modules@perl.org

I'd love to have this registered if you could find it in your heart :)

L<http://www.xray.mpe.mpg.de/mailing-lists/modules/2005-12/msg00154.html>

=head1 AUTHOR

Daniel Muey, L<http://drmuey.com/cpan_contact.pl>



( run in 0.937 second using v1.01-cache-2.11-cpan-df04353d9ac )