1 package Catalyst::Script::FastCGI;
3 use MooseX::Types::Moose qw/Str Bool Int/;
5 use namespace::autoclean;
7 sub _plack_engine_name { 'FCGI' }
9 with 'Catalyst::ScriptRole';
12 traits => [qw(Getopt)],
16 documentation => 'Specify a listening port/socket',
20 traits => [qw(Getopt)],
21 cmd_aliases => [qw/pid p/],
24 documentation => 'Specify a pidfile',
28 traits => [qw(Getopt)],
31 cmd_aliases => [qw/d detach/], # Eww, detach is here as we fucked it up.. Deliberately not documented
32 documentation => 'Daemonize (go into the background)',
36 traits => [qw(Getopt)],
40 documentation => 'Use a different FastCGI process manager class',
44 traits => [qw(Getopt)],
48 documentation => 'Log STDERR',
52 traits => [qw(Getopt)],
56 documentation => 'Specify a number of child processes',
60 traits => [qw(Getopt)],
64 builder => '_build_proc_title',
65 documentation => 'Set the process title',
68 sub _build_proc_title {
70 return sprintf 'perl-fcgi-pm [%s]', $self->application_name;
78 # Munge the 'listen' arg so that Plack::Handler::FCGI will accept it.
82 if (defined (my $listen = $self->listen)) {
89 sub _plack_loader_args {
92 my $opts = Data::OptList::mkopt([
93 qw/manager nproc proc_title/,
95 daemonize => [ 'daemon' ],
96 keep_stderr => [ 'keeperr' ],
97 listen => [ '_listen' ],
100 my %args = map { $_->[0] => $self->${ \($_->[1] ? $_->[1]->[0] : $_->[0]) } } @$opts;
102 # Plack::Handler::FCGI thinks manager => undef means "use no manager".
103 delete $args{'manager'} unless defined $args{'manager'};
108 sub _application_args {
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;
127 Catalyst::Script::FastCGI - The FastCGI Catalyst Script
131 myapp_fastcgi.pl [options]
134 -? --help display this help and exits
135 -l --listen Socket path to listen on
136 (defaults to standard input)
137 can be HOST:PORT, :PORT or a
139 -n --nproc specify number of processes to keep
140 to serve requests (defaults to 1,
142 -p --pidfile specify filename for pid file
144 -d --daemon daemonize (requires -listen)
145 -M --manager specify alternate process manager
146 (FCGI::ProcManager sub-class)
147 or empty string to disable
148 -e --keeperr send error messages to STDOUT, not
150 --proc_title set the process title
154 Run a Catalyst application as fastcgi.
158 Catalyst Contributors, see Catalyst.pm
162 This library is free software. You can redistribute it and/or modify it under
163 the same terms as Perl itself.