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 | |
27 | has host => ( isa => 'Str', is => 'ro', required => 0, default => "localhost" ); |
90b481b1 |
28 | |
29 | has fork => ( |
30 | traits => [qw(Getopt)], |
31 | cmd_aliases => 'f', |
32 | isa => 'Bool', |
33 | is => 'ro', |
34 | required => 0 |
35 | ); |
36 | |
204c6935 |
37 | has listen => ( |
38 | traits => [qw(Getopt)], |
39 | cmd_aliases => 'l', |
40 | isa => 'Int', |
41 | is => 'ro', |
42 | required => 0, |
43 | default => "3000" |
44 | ); |
45 | |
615fee7c |
46 | has pidfile => ( isa => 'Str', is => 'ro', required => 0 ); |
e46bf32c |
47 | has keepalive => ( isa => 'Bool', is => 'ro', required => 0, default => 0 ); |
615fee7c |
48 | has background => ( isa => 'Bool', is => 'ro', required => 0 ); |
49 | has app => ( isa => 'Str', is => 'ro', required => 1 ); |
50 | has restart => ( isa => 'Bool', is => 'ro', required => 0 ); |
51 | has restart_delay => ( isa => 'Int', is => 'ro', required => 0 ); |
52 | has restart_regex => ( isa => 'Str', is => 'ro', required => 0 ); |
53 | has follow_symlinks => ( isa => 'Bool', is => 'ro', required => 0 ); |
a3ca4468 |
54 | |
55 | my @argv = @ARGV; |
56 | |
57 | sub run { |
58 | my $self = shift; |
59 | |
60 | pod2usage() if $self->help; |
61 | my $app = $self->app; |
62 | Class::MOP::load_class($app); |
63 | $app->run( |
64 | $self->listen, $self->host, |
65 | { |
66 | 'fork' => $self->fork, |
67 | keepalive => $self->keepalive, |
68 | background => $self->background, |
69 | pidfile => $self->pidfile, |
615fee7c |
70 | keepalive => $self->keepalive, |
71 | restart => $self->restart, |
72 | restart_delay => $self->restart_delay, |
73 | restart_regex => qr/$self->restart_regex/, |
c1c59374 |
74 | # FIXME restart_directory => $self->restart_directory, |
615fee7c |
75 | follow_symlinks => $self->follow_symlinks, |
a3ca4468 |
76 | } |
77 | ); |
78 | |
79 | } |
5b923b0b |
80 | |
5b923b0b |
81 | |
0ba6e8aa |
82 | 1; |
e46bf32c |
83 | |
84 | =head1 NAME |
85 | |
86 | [% appprefix %]_server.pl - Catalyst Testserver |
87 | |
88 | =head1 SYNOPSIS |
89 | |
90 | [% appprefix %]_server.pl [options] |
91 | |
92 | Options: |
93 | -d -debug force debug mode |
94 | -f -fork handle each request in a new process |
95 | (defaults to false) |
96 | -? -help display this help and exits |
97 | -host host (defaults to all) |
98 | -p -port port (defaults to 3000) |
99 | -k -keepalive enable keep-alive connections |
100 | -r -restart restart when files get modified |
101 | (defaults to false) |
102 | -rd -restartdelay delay between file checks |
103 | (ignored if you have Linux::Inotify2 installed) |
104 | -rr -restartregex regex match files that trigger |
105 | a restart when modified |
106 | (defaults to '\.yml$|\.yaml$|\.conf|\.pm$') |
107 | -restartdirectory the directory to search for |
108 | modified files, can be set mulitple times |
109 | (defaults to '[SCRIPT_DIR]/..') |
110 | -follow_symlinks follow symlinks in search directories |
111 | (defaults to false. this is a no-op on Win32) |
112 | -background run the process in the background |
113 | -pidfile specify filename for pid file |
114 | |
115 | See also: |
116 | perldoc Catalyst::Manual |
117 | perldoc Catalyst::Manual::Intro |
118 | |
119 | =head1 DESCRIPTION |
120 | |
121 | Run a Catalyst Testserver for this application. |
122 | |
123 | =head1 AUTHORS |
124 | |
125 | Catalyst Contributors, see Catalyst.pm |
126 | |
127 | =head1 COPYRIGHT |
128 | |
129 | This library is free software. You can redistribute it and/or modify |
130 | it under the same terms as Perl itself. |
131 | |
132 | =cut |