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} = $self->follow_symlinks;
164 $args{directories} = $self->restart_directory;
165 $args{sleep_interval} = $self->restart_delay;
166 $args{filter} = qr/$self->restart_regex/;
168 my $restarter = $subclass->new(
170 start_sub => $self->runner,
174 $restarter->run_and_watch;
186 # If we load this here, then in the case of a restarter, it does not
187 # need to be reloaded for each restart.
190 # If this isn't done, then the Catalyst::Devel tests for the restarter
192 $| = 1 if $ENV{HARNESS_ACTIVE};
195 $self->usage if $self->help;
196 my $app = $self->app;
197 Class::MOP::load_class($app);
199 if ( $self->debug ) {
200 $ENV{CATALYST_DEBUG} = 1;
205 $self->listen, $self->host,
207 'fork' => $self->fork,
208 keepalive => $self->keepalive,
209 background => $self->background,
210 pidfile => $self->pidfile,
211 keepalive => $self->keepalive,
212 follow_symlinks => $self->follow_symlinks,
219 __PACKAGE__->meta->make_immutable;
225 [% appprefix %]_server.pl - Catalyst Testserver
229 [% appprefix %]_server.pl [options]
232 -d --debug force debug mode
233 -f --fork handle each request in a new process
235 -h --help display this help and exits
236 --host host (defaults to all)
237 -p --port port (defaults to 3000)
238 -k --keepalive enable keep-alive connections
239 -r --restart restart when files get modified
241 --rd --restartdelay delay between file checks
242 (ignored if you have Linux::Inotify2 installed)
243 --rr --restartregex regex match files that trigger
244 a restart when modified
245 (defaults to '\.yml$|\.yaml$|\.conf|\.pm$')
246 --rdir --restartdirectory the directory to search for
247 modified files, can be set mulitple times
248 (defaults to '[SCRIPT_DIR]/..')
249 --sym --follow_symlinks follow symlinks in search directories
250 (defaults to false. this is a no-op on Win32)
251 --bg --background run the process in the background
252 --pid --pidfile specify filename for pid file
255 perldoc Catalyst::Manual
256 perldoc Catalyst::Manual::Intro
260 Run a Catalyst Testserver for this application.
264 Catalyst Contributors, see Catalyst.pm
268 This library is free software. You can redistribute it and/or modify
269 it under the same terms as Perl itself.