Commit | Line | Data |
0ba6e8aa |
1 | package Catalyst::Script::FastCGI; |
2 | |
cc999ce2 |
3 | BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' } |
4 | use FindBin qw/$Bin/; |
5 | use lib "$Bin/../lib"; |
6 | use Pod::Usage; |
7 | use Moose; |
2adf69c3 |
8 | use namespace::autoclean; |
cc999ce2 |
9 | |
10 | with 'MooseX::Getopt'; |
11 | |
f4dc8d2f |
12 | has help => ( |
13 | traits => [qw(Getopt)], |
14 | cmd_aliases => 'h', |
15 | isa => 'Bool', |
16 | is => 'ro', |
17 | documentation => qq{ display this help and exits }, |
18 | ); |
19 | |
20 | has listen => ( |
21 | traits => [qw(Getopt)], |
22 | cmd_aliases => 'l', |
23 | isa => 'Int', |
24 | is => 'ro', |
25 | default => "3000", |
26 | documentation => qq{ specify a different listening port } |
27 | ); |
28 | |
29 | has pidfile => ( |
30 | traits => [qw(Getopt)], |
31 | cmd_aliases => 'pid', |
32 | isa => 'Str', |
33 | is => 'ro', |
34 | documentation => qq{ specify a pidfile } |
35 | ); |
36 | |
37 | has daemon => ( |
38 | isa => 'Bool', |
39 | is => 'ro', |
40 | traits => [qw(Getopt)], |
41 | cmd_aliases => 'd', |
42 | documentation => qq{ daemonize } |
43 | ); |
44 | |
45 | has manager => ( |
46 | isa => 'Str', |
47 | is => 'ro', |
48 | traits => [qw(Getopt)], |
49 | cmd_aliases => 'm', |
50 | documentation => qq{ use a different FastCGI manager } |
51 | ); |
52 | |
53 | has keep_stderr => ( |
54 | traits => [qw(Getopt)], |
55 | cmd_aliases => 'std', |
56 | isa => 'Bool', |
57 | is => 'ro', |
58 | documentation => qq{ log STDERR } |
59 | ); |
60 | |
61 | has nproc => ( |
62 | traits => [qw(Getopt)], |
63 | cmd_aliases => 'np', |
64 | isa => 'Int', |
65 | is => 'ro', |
66 | documentation => qq{ specify an nproc } |
67 | ); |
68 | |
69 | has detach => ( |
70 | traits => [qw(Getopt)], |
71 | cmd_aliases => 'det', |
72 | isa => 'Bool', |
73 | is => 'ro', |
74 | documentation => qq{ detach this FastCGI process } |
75 | ); |
76 | |
d9a32f71 |
77 | has _app => ( |
78 | reader => 'app', |
79 | init_arg => 'app', |
80 | traits => [qw(NoGetopt)], |
81 | isa => 'Str', |
82 | is => 'ro', |
83 | ); |
cc999ce2 |
84 | |
85 | sub run { |
86 | my $self = shift; |
57dc50b0 |
87 | |
cc999ce2 |
88 | pod2usage() if $self->help; |
89 | my $app = $self->app; |
90 | Class::MOP::load_class($app); |
335130bc |
91 | $app->run( |
cc999ce2 |
92 | $self->listen, |
57dc50b0 |
93 | { |
cc999ce2 |
94 | nproc => $self->nproc, |
95 | pidfile => $self->pidfile, |
96 | manager => $self->manager, |
97 | detach => $self->detach, |
98 | keep_stderr => $self->keep_stderr, |
57dc50b0 |
99 | } |
cc999ce2 |
100 | ); |
101 | |
102 | } |
103 | |
0ba6e8aa |
104 | 1; |