1 package Catalyst::Script::FastCGI;
4 use namespace::autoclean;
6 sub _plack_engine_name { 'FCGI' }
8 with 'Catalyst::ScriptRole';
11 traits => [qw(Getopt)],
15 documentation => 'Specify a listening port/socket',
19 traits => [qw(Getopt)],
20 cmd_aliases => [qw/pid p/],
23 documentation => 'Specify a pidfile',
27 traits => [qw(Getopt)],
30 cmd_aliases => [qw/d detach/], # Eww, detach is here as we fucked it up.. Deliberately not documented
31 documentation => 'Daemonize (go into the background)',
35 traits => [qw(Getopt)],
39 documentation => 'Use a different FastCGI process manager class',
43 traits => [qw(Getopt)],
47 documentation => 'Log STDERR',
51 traits => [qw(Getopt)],
55 documentation => 'Specify a number of child processes',
59 traits => [qw(Getopt)],
63 builder => '_build_proc_title',
64 documentation => 'Set the process title',
67 sub _build_proc_title {
69 return sprintf 'perl-fcgi-pm [%s]', $self->application_name;
77 # Munge the 'listen' arg so that Plack::Handler::FCGI will accept it.
81 if (defined (my $listen = $self->listen)) {
88 sub _plack_loader_args {
91 my $opts = Data::OptList::mkopt([
92 qw/manager nproc proc_title/,
94 daemonize => [ 'daemon' ],
95 keep_stderr => [ 'keeperr' ],
96 listen => [ '_listen' ],
99 my %args = map { $_->[0] => $self->${ \($_->[1] ? $_->[1]->[0] : $_->[0]) } } @$opts;
101 # Plack::Handler::FCGI thinks manager => undef means "use no manager".
102 delete $args{'manager'} unless defined $args{'manager'};
107 around _application_args => sub {
108 my ($orig, $self) = @_;
113 nproc => $self->nproc,
114 pidfile => $self->pidfile,
115 manager => $self->manager,
116 detach => $self->daemon,
117 keep_stderr => $self->keeperr,
118 proc_title => $self->proc_title,
123 __PACKAGE__->meta->make_immutable;
128 Catalyst::Script::FastCGI - The FastCGI Catalyst Script
132 myapp_fastcgi.pl [options]
135 -? --help display this help and exits
136 -l --listen Socket path to listen on
137 (defaults to standard input)
138 can be HOST:PORT, :PORT or a
140 -n --nproc specify number of processes to keep
141 to serve requests (defaults to 1,
143 -p --pidfile specify filename for pid file
145 -d --daemon daemonize (requires -listen)
146 -M --manager specify alternate process manager
147 (FCGI::ProcManager sub-class)
148 or empty string to disable
149 -e --keeperr send error messages to STDOUT, not
151 --proc_title set the process title
155 Run a Catalyst application as fastcgi.
159 L<Catalyst::ScriptRunner>
163 Catalyst Contributors, see Catalyst.pm
167 This library is free software. You can redistribute it and/or modify it under
168 the same terms as Perl itself.