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