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 Catalyst::Engine::HTTP;
15 use namespace::autoclean;
17 with 'MooseX::Getopt';
20 traits => [qw(Getopt)],
25 -d --debug force debug mode
31 traits => [qw(Getopt)],
36 -h --help display this help and exits
44 default => "localhost"
48 traits => [qw(Getopt)],
56 traits => [qw(Getopt)],
65 traits => [qw(Getopt)],
73 traits => [qw(Getopt)],
82 traits => [qw(Getopt)],
92 traits => [qw(NoGetopt)],
98 traits => [qw(Getopt)],
105 has restart_directory => (
106 traits => [qw(Getopt)],
107 cmd_aliases => 'rdir',
112 has restart_delay => (
113 traits => [qw(Getopt)],
114 cmd_aliases => 'rdel',
120 has restart_regex => (
121 traits => [qw(Getopt)],
122 cmd_aliases => 'rxp',
128 has follow_symlinks => (
129 traits => [qw(Getopt)],
130 cmd_aliases => 'sym',
148 $self->usage if $self->help;
150 if ( $self->debug ) {
151 $ENV{CATALYST_DEBUG} = 1;
154 if ( $self->restart ) {
155 die "Cannot run in the background and also watch for changed files.\n"
156 if $self->background;
158 require Catalyst::Restarter;
160 my $subclass = Catalyst::Restarter->pick_subclass;
163 $args{follow_symlinks} = 1
164 if $self->follow_symlinks;
165 $args{directories} = $self->restart_directory;
166 $args{sleep_interval} = $self->restart_delay;
167 $args{filter} = qr/$self->restart_regex/;
169 my $restarter = $subclass->new(
171 start_sub => $self->runner,
175 $restarter->run_and_watch;
187 # If we load this here, then in the case of a restarter, it does not
188 # need to be reloaded for each restart.
191 # If this isn't done, then the Catalyst::Devel tests for the restarter
193 $| = 1 if $ENV{HARNESS_ACTIVE};
196 $self->usage if $self->help;
197 my $app = $self->app;
198 Class::MOP::load_class($app);
200 if ( $self->debug ) {
201 $ENV{CATALYST_DEBUG} = 1;
206 $self->listen, $self->host,
208 'fork' => $self->fork,
209 keepalive => $self->keepalive,
210 background => $self->background,
211 pidfile => $self->pidfile,
212 keepalive => $self->keepalive,
213 restart => $self->restart,
214 restart_delay => $self->restart_delay,
215 restart_regex => qr/$self->restart_regex/,
216 restart_directory => $self->restart_directory,
217 follow_symlinks => $self->follow_symlinks,
224 __PACKAGE__->meta->make_immutable;
230 [% appprefix %]_server.pl - Catalyst Testserver
234 [% appprefix %]_server.pl [options]
237 -d --debug force debug mode
238 -f --fork handle each request in a new process
240 -h --help display this help and exits
241 --host host (defaults to all)
242 -p --port port (defaults to 3000)
243 -k --keepalive enable keep-alive connections
244 -r --restart restart when files get modified
246 --rd --restartdelay delay between file checks
247 (ignored if you have Linux::Inotify2 installed)
248 --rr --restartregex regex match files that trigger
249 a restart when modified
250 (defaults to '\.yml$|\.yaml$|\.conf|\.pm$')
251 --rdir --restartdirectory the directory to search for
252 modified files, can be set mulitple times
253 (defaults to '[SCRIPT_DIR]/..')
254 --sym --follow_symlinks follow symlinks in search directories
255 (defaults to false. this is a no-op on Win32)
256 --bg --background run the process in the background
257 --pid --pidfile specify filename for pid file
260 perldoc Catalyst::Manual
261 perldoc Catalyst::Manual::Intro
265 Run a Catalyst Testserver for this application.
269 Catalyst Contributors, see Catalyst.pm
273 This library is free software. You can redistribute it and/or modify
274 it under the same terms as Perl itself.