Rename to Catalyst-View-Component-SubInclude
[catagits/Catalyst-View-Component-SubInclude.git] / t / ESITest / script / esitest_server.pl
1 #!C:\Perl\bin\perl.exe -w
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/../lib";
15 use lib "$FindBin::Bin/../../../lib";
16
17 my $debug             = 0;
18 my $fork              = 0;
19 my $help              = 0;
20 my $host              = undef;
21 my $port              = $ENV{ESITEST_PORT} || $ENV{CATALYST_PORT} || 3000;
22 my $keepalive         = 0;
23 my $restart           = $ENV{ESITEST_RELOAD} || $ENV{CATALYST_RELOAD} || 0;
24 my $restart_delay     = 1;
25 my $restart_regex     = '(?:/|^)(?!\.#).+(?:\.yml$|\.yaml$|\.conf|\.pm)$';
26 my $restart_directory = undef;
27 my $follow_symlinks   = 0;
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     'followsymlinks'      => \$follow_symlinks,
43 );
44
45 pod2usage(1) if $help;
46
47 if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) {
48     $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
49 }
50 if ( $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.
56 require ESITest;
57
58 ESITest->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
69 1;
70
71 =head1 NAME
72
73 esitest_server.pl - Catalyst Testserver
74
75 =head1 SYNOPSIS
76
77 esitest_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
104 Run a Catalyst Testserver for this application.
105
106 =head1 AUTHORS
107
108 Catalyst Contributors, see Catalyst.pm
109
110 =head1 COPYRIGHT
111
112 This library is free software, you can redistribute it and/or modify
113 it under the same terms as Perl itself.
114
115 =cut