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',
108 isa => 'ArrayRef[Str]',
110 predicate => '_has_restart_directory',
113 has restart_delay => (
114 traits => [qw(Getopt)],
115 cmd_aliases => 'rdel',
118 predicate => '_has_restart_delay',
121 has restart_regex => (
122 traits => [qw(Getopt)],
123 cmd_aliases => 'rxp',
126 predicate => '_has_restart_regex',
129 has follow_symlinks => (
130 traits => [qw(Getopt)],
131 cmd_aliases => 'sym',
134 predicate => '_has_follow_symlinks',
150 $self->usage if $self->help;
152 if ( $self->debug ) {
153 $ENV{CATALYST_DEBUG} = 1;
156 # If we load this here, then in the case of a restarter, it does not
157 # need to be reloaded for each restart.
160 # If this isn't done, then the Catalyst::Devel tests for the restarter
162 $| = 1 if $ENV{HARNESS_ACTIVE};
164 if ( $self->restart ) {
165 die "Cannot run in the background and also watch for changed files.\n"
166 if $self->background;
168 require Catalyst::Restarter;
170 my $subclass = Catalyst::Restarter->pick_subclass;
173 $args{follow_symlinks} = $self->follow_symlinks
174 if $self->_has_follow_symlinks;
175 $args{directories} = $self->restart_directory
176 if $self->_has_restart_directory;
177 $args{sleep_interval} = $self->restart_delay
178 if $self->_has_restart_delay;
179 $args{filter} = qr/$self->restart_regex/
180 if $self->_has_restart_regex;
182 my $restarter = $subclass->new(
184 start_sub => sub { $self->_run },
188 $restarter->run_and_watch;
200 my $app = $self->app;
201 Class::MOP::load_class($app);
204 $self->listen, $self->host,
206 'fork' => $self->fork,
207 keepalive => $self->keepalive,
208 background => $self->background,
209 pidfile => $self->pidfile,
210 keepalive => $self->keepalive,
211 follow_symlinks => $self->follow_symlinks,
218 __PACKAGE__->meta->make_immutable;
224 [% appprefix %]_server.pl - Catalyst Testserver
228 [% appprefix %]_server.pl [options]
231 -d --debug force debug mode
232 -f --fork handle each request in a new process
234 -h --help display this help and exits
235 --host host (defaults to all)
236 -p --port port (defaults to 3000)
237 -k --keepalive enable keep-alive connections
238 -r --restart restart when files get modified
240 --rd --restartdelay delay between file checks
241 (ignored if you have Linux::Inotify2 installed)
242 --rr --restartregex regex match files that trigger
243 a restart when modified
244 (defaults to '\.yml$|\.yaml$|\.conf|\.pm$')
245 --rdir --restartdirectory the directory to search for
246 modified files, can be set mulitple times
247 (defaults to '[SCRIPT_DIR]/..')
248 --sym --follow_symlinks follow symlinks in search directories
249 (defaults to false. this is a no-op on Win32)
250 --bg --background run the process in the background
251 --pid --pidfile specify filename for pid file
254 perldoc Catalyst::Manual
255 perldoc Catalyst::Manual::Intro
259 Run a Catalyst Testserver for this application.
263 Catalyst Contributors, see Catalyst.pm
267 This library is free software. You can redistribute it and/or modify
268 it under the same terms as Perl itself.