Commit | Line | Data |
0ba6e8aa |
1 | package Catalyst::Script::Server; |
2 | |
53b08cf9 |
3 | BEGIN { |
4 | $ENV{CATALYST_ENGINE} ||= 'HTTP'; |
5 | $ENV{CATALYST_SCRIPT_GEN} = 31; |
6 | require Catalyst::Engine::HTTP; |
7 | } |
5b923b0b |
8 | |
a3ca4468 |
9 | use FindBin qw/$Bin/; |
10 | use lib "$Bin/../lib"; |
11 | use Pod::Usage; |
12 | use Moose; |
13 | use Catalyst::Engine::HTTP; |
14 | use namespace::clean -except => [ qw(meta) ]; |
15 | |
16 | with 'MooseX::Getopt'; |
17 | |
e46bf32c |
18 | has help => ( |
19 | traits => [qw(Getopt)], |
90b481b1 |
20 | cmd_aliases => 'h', |
e46bf32c |
21 | isa => 'Bool', |
22 | is => 'ro', |
23 | required => 0, |
90b481b1 |
24 | default => 0, |
e46bf32c |
25 | ); |
26 | |
41b55019 |
27 | has host => ( |
28 | isa => 'Str', |
29 | is => 'ro', |
30 | required => 0, |
31 | default => "localhost" |
32 | ); |
90b481b1 |
33 | |
34 | has fork => ( |
35 | traits => [qw(Getopt)], |
36 | cmd_aliases => 'f', |
37 | isa => 'Bool', |
38 | is => 'ro', |
39 | required => 0 |
40 | ); |
41 | |
204c6935 |
42 | has listen => ( |
43 | traits => [qw(Getopt)], |
44 | cmd_aliases => 'l', |
45 | isa => 'Int', |
46 | is => 'ro', |
47 | required => 0, |
48 | default => "3000" |
49 | ); |
50 | |
41b55019 |
51 | has pidfile => ( |
52 | traits => [qw(Getopt)], |
53 | cmd_aliases => 'pf', |
54 | isa => 'Str', |
55 | is => 'ro', |
56 | required => 0 |
57 | ); |
58 | |
bd31e11f |
59 | has keepalive => ( |
60 | traits => [qw(Getopt)], |
61 | cmd_aliases => 'k', |
62 | isa => 'Bool', |
63 | is => 'ro', |
64 | required => 0, |
65 | default => 0 |
66 | ); |
67 | |
615fee7c |
68 | has background => ( isa => 'Bool', is => 'ro', required => 0 ); |
bd31e11f |
69 | has app => ( isa => 'Str', is => 'ro', required => 1 ); # THIS IS FUCKING RETARDED HALP PLZ |
615fee7c |
70 | has restart => ( isa => 'Bool', is => 'ro', required => 0 ); |
71 | has restart_delay => ( isa => 'Int', is => 'ro', required => 0 ); |
72 | has restart_regex => ( isa => 'Str', is => 'ro', required => 0 ); |
73 | has follow_symlinks => ( isa => 'Bool', is => 'ro', required => 0 ); |
a3ca4468 |
74 | |
75 | my @argv = @ARGV; |
76 | |
77 | sub run { |
78 | my $self = shift; |
79 | |
80 | pod2usage() if $self->help; |
81 | my $app = $self->app; |
82 | Class::MOP::load_class($app); |
83 | $app->run( |
84 | $self->listen, $self->host, |
85 | { |
86 | 'fork' => $self->fork, |
87 | keepalive => $self->keepalive, |
88 | background => $self->background, |
89 | pidfile => $self->pidfile, |
615fee7c |
90 | keepalive => $self->keepalive, |
91 | restart => $self->restart, |
92 | restart_delay => $self->restart_delay, |
93 | restart_regex => qr/$self->restart_regex/, |
c1c59374 |
94 | # FIXME restart_directory => $self->restart_directory, |
615fee7c |
95 | follow_symlinks => $self->follow_symlinks, |
a3ca4468 |
96 | } |
97 | ); |
98 | |
99 | } |
5b923b0b |
100 | |
5b923b0b |
101 | |
0ba6e8aa |
102 | 1; |
e46bf32c |
103 | |
104 | =head1 NAME |
105 | |
106 | [% appprefix %]_server.pl - Catalyst Testserver |
107 | |
108 | =head1 SYNOPSIS |
109 | |
110 | [% appprefix %]_server.pl [options] |
111 | |
112 | Options: |
113 | -d -debug force debug mode |
114 | -f -fork handle each request in a new process |
115 | (defaults to false) |
116 | -? -help display this help and exits |
117 | -host host (defaults to all) |
118 | -p -port port (defaults to 3000) |
119 | -k -keepalive enable keep-alive connections |
120 | -r -restart restart when files get modified |
121 | (defaults to false) |
122 | -rd -restartdelay delay between file checks |
123 | (ignored if you have Linux::Inotify2 installed) |
124 | -rr -restartregex regex match files that trigger |
125 | a restart when modified |
126 | (defaults to '\.yml$|\.yaml$|\.conf|\.pm$') |
127 | -restartdirectory the directory to search for |
128 | modified files, can be set mulitple times |
129 | (defaults to '[SCRIPT_DIR]/..') |
130 | -follow_symlinks follow symlinks in search directories |
131 | (defaults to false. this is a no-op on Win32) |
132 | -background run the process in the background |
133 | -pidfile specify filename for pid file |
134 | |
135 | See also: |
136 | perldoc Catalyst::Manual |
137 | perldoc Catalyst::Manual::Intro |
138 | |
139 | =head1 DESCRIPTION |
140 | |
141 | Run a Catalyst Testserver for this application. |
142 | |
143 | =head1 AUTHORS |
144 | |
145 | Catalyst Contributors, see Catalyst.pm |
146 | |
147 | =head1 COPYRIGHT |
148 | |
149 | This library is free software. You can redistribute it and/or modify |
150 | it under the same terms as Perl itself. |
151 | |
152 | =cut |