removed default => 0s
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Script / Server.pm
CommitLineData
0ba6e8aa 1package Catalyst::Script::Server;
2
53b08cf9 3BEGIN {
4 $ENV{CATALYST_ENGINE} ||= 'HTTP';
5 $ENV{CATALYST_SCRIPT_GEN} = 31;
6 require Catalyst::Engine::HTTP;
7}
5b923b0b 8
a3ca4468 9use FindBin qw/$Bin/;
10use lib "$Bin/../lib";
11use Pod::Usage;
12use Moose;
4ebd5ecf 13#use Catalyst::Engine::HTTP;
59804176 14use namespace::autoclean;
a3ca4468 15
16with 'MooseX::Getopt';
17
e46bf32c 18has help => (
19 traits => [qw(Getopt)],
90b481b1 20 cmd_aliases => 'h',
e46bf32c 21 isa => 'Bool',
22 is => 'ro',
8bae939b 23 ,
e46bf32c 24);
25
41b55019 26has host => (
27 isa => 'Str',
28 is => 'ro',
50d48a87 29 ,
41b55019 30 default => "localhost"
31);
90b481b1 32
33has fork => (
34 traits => [qw(Getopt)],
35 cmd_aliases => 'f',
36 isa => 'Bool',
37 is => 'ro',
50d48a87 38
90b481b1 39);
40
204c6935 41has listen => (
42 traits => [qw(Getopt)],
43 cmd_aliases => 'l',
44 isa => 'Int',
45 is => 'ro',
50d48a87 46 ,
204c6935 47 default => "3000"
48);
49
41b55019 50has pidfile => (
51 traits => [qw(Getopt)],
b6aaf142 52 cmd_aliases => 'pid',
41b55019 53 isa => 'Str',
54 is => 'ro',
50d48a87 55
41b55019 56);
57
bd31e11f 58has keepalive => (
59 traits => [qw(Getopt)],
60 cmd_aliases => 'k',
61 isa => 'Bool',
62 is => 'ro',
50d48a87 63 ,
8bae939b 64
bd31e11f 65);
66
3954573c 67has background => (
68 traits => [qw(Getopt)],
69 cmd_aliases => 'bg',
70 isa => 'Bool',
71 is => 'ro',
3954573c 72);
73
4ebd5ecf 74
80a909c2 75has _app => (
76 reader => 'app',
77 init_arg => 'app',
78 traits => [qw(NoGetopt)],
4b3881d4 79 isa => 'Str',
80 is => 'ro',
4b3881d4 81);
82
8f01ed5f 83has restart => (
84 traits => [qw(Getopt)],
85 cmd_aliases => 'r',
86 isa => 'Bool',
87 is => 'ro',
50d48a87 88
8f01ed5f 89);
90
70871584 91has restart_delay => (
92 traits => [qw(Getopt)],
93 cmd_aliases => 'rdel',
94 isa => 'Int',
95 is => 'ro',
50d48a87 96
70871584 97);
98
ee7aabd6 99has restart_regex => (
100 traits => [qw(Getopt)],
101 cmd_aliases => 'rxp',
102 isa => 'Str',
103 is => 'ro',
50d48a87 104
ee7aabd6 105);
106
bbd42ac8 107has follow_symlinks => (
108 traits => [qw(Getopt)],
109 cmd_aliases => 'sym',
110 isa => 'Bool',
111 is => 'ro',
50d48a87 112
bbd42ac8 113);
a3ca4468 114
8bae939b 115sub usage {
116 my ($self) = shift;
117
118 return pod2usage();
119
120}
121
a3ca4468 122my @argv = @ARGV;
123
124sub run {
125 my $self = shift;
126
8bae939b 127 $self->usage if $self->help;
a3ca4468 128 my $app = $self->app;
129 Class::MOP::load_class($app);
130 $app->run(
131 $self->listen, $self->host,
132 {
4b3881d4 133 'fork' => $self->fork,
134 keepalive => $self->keepalive,
135 background => $self->background,
136 pidfile => $self->pidfile,
615fee7c 137 keepalive => $self->keepalive,
138 restart => $self->restart,
139 restart_delay => $self->restart_delay,
140 restart_regex => qr/$self->restart_regex/,
c1c59374 141# FIXME restart_directory => $self->restart_directory,
615fee7c 142 follow_symlinks => $self->follow_symlinks,
a3ca4468 143 }
144 );
145
146}
5b923b0b 147
5b923b0b 148
0ba6e8aa 1491;
e46bf32c 150
151=head1 NAME
152
153[% appprefix %]_server.pl - Catalyst Testserver
154
155=head1 SYNOPSIS
156
157[% appprefix %]_server.pl [options]
158
159 Options:
4b3881d4 160 -d --debug force debug mode
161 -f --fork handle each request in a new process
e46bf32c 162 (defaults to false)
4b3881d4 163 -h --help display this help and exits
164 --host host (defaults to all)
165 -p --port port (defaults to 3000)
166 -k --keepalive enable keep-alive connections
167 -r --restart restart when files get modified
168 (defaults to false)
169 --rd --restartdelay delay between file checks
e46bf32c 170 (ignored if you have Linux::Inotify2 installed)
4b3881d4 171 --rr --restartregex regex match files that trigger
e46bf32c 172 a restart when modified
173 (defaults to '\.yml$|\.yaml$|\.conf|\.pm$')
4b3881d4 174 --rdir --restartdirectory the directory to search for
e46bf32c 175 modified files, can be set mulitple times
176 (defaults to '[SCRIPT_DIR]/..')
4b3881d4 177 --sym --follow_symlinks follow symlinks in search directories
e46bf32c 178 (defaults to false. this is a no-op on Win32)
4b3881d4 179 --bg --background run the process in the background
180 --pid --pidfile specify filename for pid file
e46bf32c 181
182 See also:
183 perldoc Catalyst::Manual
184 perldoc Catalyst::Manual::Intro
185
186=head1 DESCRIPTION
187
188Run a Catalyst Testserver for this application.
189
190=head1 AUTHORS
191
192Catalyst Contributors, see Catalyst.pm
193
194=head1 COPYRIGHT
195
196This library is free software. You can redistribute it and/or modify
197it under the same terms as Perl itself.
198
199=cut