Fix the fcgi script tests.
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Script / FastCGI.pm
CommitLineData
0ba6e8aa 1package Catalyst::Script::FastCGI;
cc999ce2 2use Moose;
4e45780e 3use MooseX::Types::Moose qw/Str Bool Int/;
6640e166 4use Data::OptList;
2adf69c3 5use namespace::autoclean;
cc999ce2 6
c821df21 7sub _plack_engine_name { 'FCGI' }
8
d3082fac 9with 'Catalyst::ScriptRole';
f4dc8d2f 10
11has listen => (
ad8b4c91 12 traits => [qw(Getopt)],
13 cmd_aliases => 'l',
14 isa => Str,
15 is => 'ro',
d3082fac 16 documentation => 'Specify a listening port/socket',
f4dc8d2f 17);
18
19has pidfile => (
ad8b4c91 20 traits => [qw(Getopt)],
ad08ab75 21 cmd_aliases => [qw/pid p/],
ad8b4c91 22 isa => Str,
23 is => 'ro',
d3082fac 24 documentation => 'Specify a pidfile',
f4dc8d2f 25);
26
ab7eb5a9 27has daemon => (
ad8b4c91 28 traits => [qw(Getopt)],
29 isa => Bool,
30 is => 'ro',
7388bcae 31 cmd_aliases => [qw/d detach/], # Eww, detach is here as we fucked it up.. Deliberately not documented
53c6ec79 32 documentation => 'Daemonize (go into the background)',
f4dc8d2f 33);
34
ab7eb5a9 35has manager => (
ad8b4c91 36 traits => [qw(Getopt)],
37 isa => Str,
38 is => 'ro',
39 cmd_aliases => 'M',
53c6ec79 40 documentation => 'Use a different FastCGI process manager class',
f4dc8d2f 41);
42
53c6ec79 43has keeperr => (
ad8b4c91 44 traits => [qw(Getopt)],
45 cmd_aliases => 'e',
46 isa => Bool,
47 is => 'ro',
d3082fac 48 documentation => 'Log STDERR',
f4dc8d2f 49);
50
51has nproc => (
ad8b4c91 52 traits => [qw(Getopt)],
53 cmd_aliases => 'n',
54 isa => Int,
55 is => 'ro',
53c6ec79 56 documentation => 'Specify a number of child processes',
f4dc8d2f 57);
58
36a53c3a 59sub _plack_loader_args {
60 my ($self) = shift;
61 return (
6640e166 62 map { $_->[0] => $self->${ \($_->[1] ? $_->[1]->[0] : $_->[0]) } }
63 Data::OptList::mkopt([
64 qw/pidfile listen manager nproc keep_stderr/,
65 detach => [ 'daemon'],
66 ])
36a53c3a 67 );
68}
69
d3082fac 70sub _application_args {
71 my ($self) = shift;
72 return (
cc999ce2 73 $self->listen,
57dc50b0 74 {
cc999ce2 75 nproc => $self->nproc,
76 pidfile => $self->pidfile,
77 manager => $self->manager,
e1d59dc4 78 detach => $self->daemon,
53c6ec79 79 keep_stderr => $self->keeperr,
57dc50b0 80 }
cc999ce2 81 );
cc999ce2 82}
83
73e4f0f1 84__PACKAGE__->meta->make_immutable;
85
d3082fac 86=head1 NAME
87
88Catalyst::Script::FastCGI - The FastCGI Catalyst Script
89
90=head1 SYNOPSIS
91
53c6ec79 92 myapp_fastcgi.pl [options]
93
94 Options:
ad8b4c91 95 -? --help display this help and exits
96 -l --listen Socket path to listen on
97 (defaults to standard input)
98 can be HOST:PORT, :PORT or a
99 filesystem path
100 -n --nproc specify number of processes to keep
101 to serve requests (defaults to 1,
102 requires -listen)
103 -p --pidfile specify filename for pid file
104 (requires -listen)
105 -d --daemon daemonize (requires -listen)
106 -M --manager specify alternate process manager
107 (FCGI::ProcManager sub-class)
108 or empty string to disable
109 -e --keeperr send error messages to STDOUT, not
110 to the webserver
d3082fac 111
112=head1 DESCRIPTION
113
53c6ec79 114Run a Catalyst application as fastcgi.
d3082fac 115
116=head1 AUTHORS
117
118Catalyst Contributors, see Catalyst.pm
119
120=head1 COPYRIGHT
121
122This library is free software. You can redistribute it and/or modify it under
123the same terms as Perl itself.
124
125=cut