1 package Catalyst::Script::Server;
4 $ENV{CATALYST_ENGINE} ||= 'HTTP';
5 $ENV{CATALYST_SCRIPT_GEN} = 31;
6 require Catalyst::Engine::HTTP;
10 use lib "$Bin/../lib";
13 use Catalyst::Restarter;
14 use namespace::autoclean;
16 with 'MooseX::Getopt';
19 traits => [qw(Getopt)],
24 -d --debug force debug mode
30 traits => [qw(Getopt)],
35 -h --help display this help and exits
43 default => "localhost"
47 traits => [qw(Getopt)],
55 traits => [qw(Getopt)],
64 traits => [qw(Getopt)],
72 traits => [qw(Getopt)],
81 traits => [qw(Getopt)],
91 traits => [qw(NoGetopt)],
97 traits => [qw(Getopt)],
104 has restart_directory => (
105 traits => [qw(Getopt)],
106 cmd_aliases => 'rdir',
107 isa => 'ArrayRef[Str]',
109 predicate => '_has_restart_directory',
112 has restart_delay => (
113 traits => [qw(Getopt)],
114 cmd_aliases => 'rdel',
117 predicate => '_has_restart_delay',
120 has restart_regex => (
121 traits => [qw(Getopt)],
122 cmd_aliases => 'rxp',
125 predicate => '_has_restart_regex',
128 has follow_symlinks => (
129 traits => [qw(Getopt)],
130 cmd_aliases => 'sym',
133 predicate => '_has_follow_symlinks',
148 $self->usage if $self->help;
150 if ( $self->debug ) {
151 $ENV{CATALYST_DEBUG} = 1;
154 # If we load this here, then in the case of a restarter, it does not
155 # need to be reloaded for each restart.
158 # If this isn't done, then the Catalyst::Devel tests for the restarter
160 $| = 1 if $ENV{HARNESS_ACTIVE};
162 if ( $self->restart ) {
163 die "Cannot run in the background and also watch for changed files.\n"
164 if $self->background;
166 require Catalyst::Restarter;
168 my $subclass = Catalyst::Restarter->pick_subclass;
171 $args{follow_symlinks} = $self->follow_symlinks
172 if $self->_has_follow_symlinks;
173 $args{directories} = $self->restart_directory
174 if $self->_has_restart_directory;
175 $args{sleep_interval} = $self->restart_delay
176 if $self->_has_restart_delay;
177 $args{filter} = qr/$self->restart_regex/
178 if $self->_has_restart_regex;
180 my $restarter = $subclass->new(
182 start_sub => sub { $self->_run },
183 argv => \$self->ARGV,
186 $restarter->run_and_watch;
198 my $app = $self->app;
199 Class::MOP::load_class($app);
202 $self->listen, $self->host,
204 'fork' => $self->fork,
205 keepalive => $self->keepalive,
206 background => $self->background,
207 pidfile => $self->pidfile,
208 keepalive => $self->keepalive,
209 follow_symlinks => $self->follow_symlinks,
216 __PACKAGE__->meta->make_immutable;
222 [% appprefix %]_server.pl - Catalyst Testserver
226 [% appprefix %]_server.pl [options]
229 -d --debug force debug mode
230 -f --fork handle each request in a new process
232 -h --help display this help and exits
233 --host host (defaults to all)
234 -p --port port (defaults to 3000)
235 -k --keepalive enable keep-alive connections
236 -r --restart restart when files get modified
238 --rd --restartdelay delay between file checks
239 (ignored if you have Linux::Inotify2 installed)
240 --rr --restartregex regex match files that trigger
241 a restart when modified
242 (defaults to '\.yml$|\.yaml$|\.conf|\.pm$')
243 --rdir --restartdirectory the directory to search for
244 modified files, can be set mulitple times
245 (defaults to '[SCRIPT_DIR]/..')
246 --sym --follow_symlinks follow symlinks in search directories
247 (defaults to false. this is a no-op on Win32)
248 --bg --background run the process in the background
249 --pid --pidfile specify filename for pid file
252 perldoc Catalyst::Manual
253 perldoc Catalyst::Manual::Intro
257 Run a Catalyst Testserver for this application.
261 Catalyst Contributors, see Catalyst.pm
265 This library is free software. You can redistribute it and/or modify
266 it under the same terms as Perl itself.