1 package Catalyst::Engine::FastCGI;
4 use base 'Catalyst::Engine::CGI';
9 Catalyst::Engine::FastCGI - FastCGI Engine
13 This is the FastCGI engine.
15 =head1 OVERLOADED METHODS
17 This class overloads some methods from C<Catalyst::Engine::CGI>.
21 =item $self->run($c, $listen, { option => value, ... })
23 Starts the FastCGI server. If C<$listen> is set, then it specifies a
24 location to listen for FastCGI requests;
27 /path listen via Unix sockets on /path
28 :port listen via TCP on port on all interfaces
29 hostname:port listen via TCP on port bound to hostname
31 Options may also be specified;
34 leave_umask Set to 1 to disable setting umask to 0
36 nointr Do not allow the listener to be
38 nproc Specify a number of processes for
44 my ( $self, $class, $listen, $options ) = @_;
48 my $old_umask = umask;
49 unless ( $options->{leave_umask} ) {
52 $sock = FCGI::OpenSocket( $listen, 100 )
53 or die "failed to open FastCGI socket; $!";
54 unless ( $options->{leave_umask} ) {
60 or die "STDIN is not a socket; specify a listen location";
66 FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, $sock,
67 ( $options->{nointr} ? 0 : &FCGI::FAIL_ACCEPT_ON_INTR ),
72 if ( $listen and ( $options->{nproc} || 1 ) > 1 ) {
73 require FCGI::ProcManager;
75 FCGI::ProcManager->new( { n_processes => $options->{nproc} } );
76 $proc_manager->pm_manage();
79 while ( $request->Accept >= 0 ) {
80 $proc_manager && $proc_manager->pm_pre_dispatch();
81 $class->handle_request;
82 $proc_manager && $proc_manager->pm_pre_dispatch();
86 =item $self->write($c, $buffer)
91 my ( $self, $c, $buffer ) = @_;
93 unless ( $self->{_prepared_write} ) {
94 $self->prepare_write($c);
95 $self->{_prepared_write} = 1;
98 # FastCGI does not stream data properly if using 'print $handle',
99 # but a syswrite appears to work properly.
100 *STDOUT->syswrite($buffer);
107 L<Catalyst>, L<FCGI>.
111 Sebastian Riedel, <sri@cpan.org>
113 Christian Hansen, <ch@ngmedia.com>
115 Andy Grundman, <andy@hybridized.org>
119 This program is free software, you can redistribute it and/or modify it under
120 the same terms as Perl itself.