This class overloads some methods from C<Catalyst::Engine::CGI>.
-=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;
umask($old_umask);
}
}
- else {
+ elsif ( $^O ne 'MSWin32' ) {
-S STDIN
or die "STDIN is not a socket; specify a listen location";
}
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};
}
elsif ( $options->{detach} ) {
$self->daemon_detach();
- }
+ }
}
while ( $request->Accept >= 0 ) {
}
}
-=item $self->write($c, $buffer)
+=head2 $self->write($c, $buffer)
=cut
*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.
fork && exit;
}
-=item $self->daemon_detach( )
+=head2 $self->daemon_detach( )
Performs the second part of daemon initialisation. Specifically,
disassociates from the terminal.
sub daemon_detach {
my $self = shift;
print "FastCGI daemon started (pid $$)\n";
- open STDIN, "+</dev/null" or die $!;
- open STDOUT, ">&STDIN" or die $!;
- open STDERR, ">&STDIN" or die $!;
+ open STDIN, "+</dev/null" or die $!;
+ open STDOUT, ">&STDIN" or die $!;
+ open STDERR, ">&STDIN" or die $!;
POSIX::setsid();
}
1;
__END__
-=back
-
=head1 WEB SERVER CONFIGURATIONS
=head2 Apache 1.x, 2.x