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