initial import
[catagits/Catalyst-Component-ACCEPT_CONTEXT.git] / t / lib / script / testapp_server.pl
CommitLineData
6166f03d 1#!/usr/bin/env perl
2
3BEGIN {
4 $ENV{CATALYST_ENGINE} ||= 'HTTP';
5 $ENV{CATALYST_SCRIPT_GEN} = 31;
6 require Catalyst::Engine::HTTP;
7}
8
9use strict;
10use warnings;
11use Getopt::Long;
12use Pod::Usage;
13use FindBin;
14use lib "$FindBin::Bin/..";
15
16my $debug = 0;
17my $fork = 0;
18my $help = 0;
19my $host = undef;
20my $port = 3000;
21my $keepalive = 0;
22my $restart = 0;
23my $restart_delay = 1;
24my $restart_regex = '\.yml$|\.yaml$|\.pm$';
25my $restart_directory = undef;
26my $background = 0;
27my $pidfile = "/tmp/testapp.pid";
28
29my @argv = @ARGV;
30
31GetOptions(
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
46pod2usage(1) if $help;
47
48if ( $restart ) {
49 $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
50}
51if ( $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.
57require TestApp;
58
59TestApp->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
711;
72
73=head1 NAME
74
75testapp_server.pl - Catalyst Testserver
76
77=head1 SYNOPSIS
78
79testapp_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
109Run a Catalyst Testserver for this application.
110
111=head1 AUTHOR
112
113Sebastian Riedel, C<sri@oook.de>
114Maintained by the Catalyst Core Team.
115
116=head1 COPYRIGHT
117
118This library is free software, you can redistribute it and/or modify
119it under the same terms as Perl itself.
120
121=cut