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