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