Rename the test app into the lib directory
[catagits/Catalyst-View-Component-SubInclude.git] / t / script / esitest_server.pl
CommitLineData
e3c8a4c3 1#/usr/bin/perl -w
30726632 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/../lib";
15use lib "$FindBin::Bin/../../../lib";
16
17my $debug = 0;
18my $fork = 0;
19my $help = 0;
20my $host = undef;
21my $port = $ENV{ESITEST_PORT} || $ENV{CATALYST_PORT} || 3000;
22my $keepalive = 0;
23my $restart = $ENV{ESITEST_RELOAD} || $ENV{CATALYST_RELOAD} || 0;
24my $restart_delay = 1;
25my $restart_regex = '(?:/|^)(?!\.#).+(?:\.yml$|\.yaml$|\.conf|\.pm)$';
26my $restart_directory = undef;
27my $follow_symlinks = 0;
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 'followsymlinks' => \$follow_symlinks,
43);
44
45pod2usage(1) if $help;
46
47if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) {
48 $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
49}
50if ( $debug ) {
51 $ENV{CATALYST_DEBUG} = 1;
52}
53
54# This is require instead of use so that the above environment
55# variables can be set at runtime.
56require ESITest;
57
58ESITest->run( $port, $host, {
59 argv => \@argv,
60 'fork' => $fork,
61 keepalive => $keepalive,
62 restart => $restart,
63 restart_delay => $restart_delay,
64 restart_regex => qr/$restart_regex/,
65 restart_directory => $restart_directory,
66 follow_symlinks => $follow_symlinks,
67} );
68
691;
70
71=head1 NAME
72
73esitest_server.pl - Catalyst Testserver
74
75=head1 SYNOPSIS
76
77esitest_server.pl [options]
78
79 Options:
80 -d -debug force debug mode
81 -f -fork handle each request in a new process
82 (defaults to false)
83 -? -help display this help and exits
84 -host host (defaults to all)
85 -p -port port (defaults to 3000)
86 -k -keepalive enable keep-alive connections
87 -r -restart restart when files get modified
88 (defaults to false)
89 -rd -restartdelay delay between file checks
90 -rr -restartregex regex match files that trigger
91 a restart when modified
92 (defaults to '\.yml$|\.yaml$|\.conf|\.pm$')
93 -restartdirectory the directory to search for
94 modified files, can be set mulitple times
95 (defaults to '[SCRIPT_DIR]/..')
96 -follow_symlinks follow symlinks in search directories
97 (defaults to false. this is a no-op on Win32)
98 See also:
99 perldoc Catalyst::Manual
100 perldoc Catalyst::Manual::Intro
101
102=head1 DESCRIPTION
103
104Run a Catalyst Testserver for this application.
105
106=head1 AUTHORS
107
108Catalyst Contributors, see Catalyst.pm
109
110=head1 COPYRIGHT
111
112This library is free software, you can redistribute it and/or modify
113it under the same terms as Perl itself.
114
115=cut