Commit | Line | Data |
6166f03d |
1 | #!/usr/bin/env perl |
2 | |
3 | BEGIN { |
4 | $ENV{CATALYST_ENGINE} ||= 'HTTP'; |
5 | $ENV{CATALYST_SCRIPT_GEN} = 31; |
6 | require Catalyst::Engine::HTTP; |
7 | } |
8 | |
9 | use strict; |
10 | use warnings; |
11 | use Getopt::Long; |
12 | use Pod::Usage; |
13 | use FindBin; |
14 | use lib "$FindBin::Bin/.."; |
15 | |
16 | my $debug = 0; |
17 | my $fork = 0; |
18 | my $help = 0; |
19 | my $host = undef; |
20 | my $port = 3000; |
21 | my $keepalive = 0; |
22 | my $restart = 0; |
23 | my $restart_delay = 1; |
24 | my $restart_regex = '\.yml$|\.yaml$|\.pm$'; |
25 | my $restart_directory = undef; |
26 | my $background = 0; |
27 | my $pidfile = "/tmp/testapp.pid"; |
28 | |
29 | my @argv = @ARGV; |
30 | |
31 | GetOptions( |
32 | 'debug|d' => \$debug, |
33 | 'fork' => \$fork, |
34 | 'help|?' => \$help, |
35 | 'host=s' => \$host, |
36 | 'port=s' => \$port, |
37 | 'keepalive|k' => \$keepalive, |
38 | 'restart|r' => \$restart, |
39 | 'restartdelay|rd=s' => \$restart_delay, |
40 | 'restartregex|rr=s' => \$restart_regex, |
41 | 'restartdirectory=s' => \$restart_directory, |
42 | 'daemon' => \$background, |
43 | 'pidfile=s' => \$pidfile, |
44 | ); |
45 | |
46 | pod2usage(1) if $help; |
47 | |
48 | if ( $restart ) { |
49 | $ENV{CATALYST_ENGINE} = 'HTTP::Restarter'; |
50 | } |
51 | if ( $debug ) { |
52 | $ENV{CATALYST_DEBUG} = 1; |
53 | } |
54 | |
55 | # This is require instead of use so that the above environment |
56 | # variables can be set at runtime. |
57 | require TestApp; |
58 | |
59 | TestApp->run( $port, $host, { |
60 | argv => \@argv, |
61 | 'fork' => $fork, |
62 | keepalive => $keepalive, |
63 | restart => $restart, |
64 | restart_delay => $restart_delay, |
65 | restart_regex => qr/$restart_regex/, |
66 | restart_directory => $restart_directory, |
67 | background => $background, |
68 | pidfile => $pidfile, |
69 | } ); |
70 | |
71 | 1; |
72 | |
73 | =head1 NAME |
74 | |
75 | testapp_server.pl - Catalyst Testserver |
76 | |
77 | =head1 SYNOPSIS |
78 | |
79 | testapp_server.pl [options] |
80 | |
81 | Options: |
82 | -d -debug force debug mode |
83 | -f -fork handle each request in a new process |
84 | (defaults to false) |
85 | -? -help display this help and exits |
86 | -host host (defaults to all) |
87 | -p -port port (defaults to 3000) |
88 | -k -keepalive enable keep-alive connections |
89 | -r -restart restart when files get modified |
90 | (defaults to false) |
91 | -rd -restartdelay delay between file checks |
92 | -rr -restartregex regex match files that trigger |
93 | a restart when modified |
94 | (defaults to '\.yml$|\.yaml$|\.pm$') |
95 | -restartdirectory the directory to search for |
96 | modified files |
97 | (defaults to '../') |
98 | |
99 | -daemon background the server |
100 | -pidfile=filename store the pid if the server in filename, if |
101 | daemonizing |
102 | |
103 | See also: |
104 | perldoc Catalyst::Manual |
105 | perldoc Catalyst::Manual::Intro |
106 | |
107 | =head1 DESCRIPTION |
108 | |
109 | Run a Catalyst Testserver for this application. |
110 | |
111 | =head1 AUTHOR |
112 | |
113 | Sebastian Riedel, C<sri@oook.de> |
114 | Maintained by the Catalyst Core Team. |
115 | |
116 | =head1 COPYRIGHT |
117 | |
118 | This library is free software, you can redistribute it and/or modify |
119 | it under the same terms as Perl itself. |
120 | |
121 | =cut |