X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FFastCGI.pm;h=af96ca3d1e53c8af5aa69c552f4da9927edb2807;hb=6f2e00215dd214b31528eaf1c90345aa63fac770;hp=9ebe51b342cb3c61b5129cb82ae6971f43d096ea;hpb=526b698a2abd784cf758a8b52936e33c2a3e4442;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/FastCGI.pm b/lib/Catalyst/Engine/FastCGI.pm index 9ebe51b..af96ca3 100644 --- a/lib/Catalyst/Engine/FastCGI.pm +++ b/lib/Catalyst/Engine/FastCGI.pm @@ -17,9 +17,7 @@ This is the FastCGI engine. This class overloads some methods from C. -=over 4 - -=item $self->run($c, $listen, { option => value, ... }) +=head2 $self->run($c, $listen, { option => value, ... }) Starts the FastCGI server. If C<$listen> is set, then it specifies a location to listen for FastCGI requests; @@ -59,7 +57,7 @@ sub run { umask($old_umask); } } - else { + elsif ( $^O ne 'MSWin32' ) { -S STDIN or die "STDIN is not a socket; specify a listen location"; } @@ -78,18 +76,19 @@ sub run { if ($listen) { $options->{manager} ||= "FCGI::ProcManager"; $options->{nproc} ||= 1; - + $self->daemon_fork() if $options->{detach}; - + if ( $options->{manager} ) { eval "use $options->{manager}; 1" or die $@; - $proc_manager - = $options->{manager}->new( { + $proc_manager = $options->{manager}->new( + { n_processes => $options->{nproc}, pid_fname => $options->{pidfile}, - } ); - + } + ); + # detach *before* the ProcManager inits $self->daemon_detach() if $options->{detach}; @@ -97,7 +96,7 @@ sub run { } elsif ( $options->{detach} ) { $self->daemon_detach(); - } + } } while ( $request->Accept >= 0 ) { @@ -107,7 +106,7 @@ sub run { } } -=item $self->write($c, $buffer) +=head2 $self->write($c, $buffer) =cut @@ -124,7 +123,7 @@ sub write { *STDOUT->syswrite($buffer); } -=item $self->daemon_fork() +=head2 $self->daemon_fork() Performs the first part of daemon initialisation. Specifically, forking. STDERR, etc are still connected to a terminal. @@ -136,7 +135,7 @@ sub daemon_fork { fork && exit; } -=item $self->daemon_detach( ) +=head2 $self->daemon_detach( ) Performs the second part of daemon initialisation. Specifically, disassociates from the terminal. @@ -151,17 +150,15 @@ F). sub daemon_detach { my $self = shift; print "FastCGI daemon started (pid $$)\n"; - open STDIN, "+&STDIN" or die $!; - open STDERR, ">&STDIN" or die $!; + open STDIN, "+&STDIN" or die $!; + open STDERR, ">&STDIN" or die $!; POSIX::setsid(); } 1; __END__ -=back - =head1 WEB SERVER CONFIGURATIONS =head2 Apache 1.x, 2.x