Commit | Line | Data |
0ba6e8aa |
1 | package Catalyst::Script::FastCGI; |
cc999ce2 |
2 | use Moose; |
4e45780e |
3 | use MooseX::Types::Moose qw/Str Bool Int/; |
6640e166 |
4 | use Data::OptList; |
2adf69c3 |
5 | use namespace::autoclean; |
cc999ce2 |
6 | |
c821df21 |
7 | sub _plack_engine_name { 'FCGI' } |
8 | |
d3082fac |
9 | with 'Catalyst::ScriptRole'; |
f4dc8d2f |
10 | |
11 | has 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 | |
19 | has 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 |
27 | has 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 |
35 | has 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 |
43 | has keeperr => ( |
ad8b4c91 |
44 | traits => [qw(Getopt)], |
45 | cmd_aliases => 'e', |
46 | isa => Bool, |
47 | is => 'ro', |
d3082fac |
48 | documentation => 'Log STDERR', |
f4dc8d2f |
49 | ); |
50 | |
51 | has 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 |
59 | sub _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 |
70 | sub _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 | |
88 | Catalyst::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 |
114 | Run a Catalyst application as fastcgi. |
d3082fac |
115 | |
116 | =head1 AUTHORS |
117 | |
118 | Catalyst Contributors, see Catalyst.pm |
119 | |
120 | =head1 COPYRIGHT |
121 | |
122 | This library is free software. You can redistribute it and/or modify it under |
123 | the same terms as Perl itself. |
124 | |
125 | =cut |