todo.org: Added.
[Fumo.git] / script / fumo_server.pl
blobf056394562222662045e49008fdaee5629b819d6
1 #!/usr/bin/perl -w
3 BEGIN {
4 $ENV{CATALYST_ENGINE} ||= 'HTTP';
5 $ENV{CATALYST_SCRIPT_GEN} = 31;
6 require Catalyst::Engine::HTTP;
7 }
9 use strict;
10 use warnings;
11 use Getopt::Long;
12 use Pod::Usage;
13 use FindBin;
14 use lib "$FindBin::Bin/../lib";
16 my $debug = 0;
17 my $fork = 0;
18 my $help = 0;
19 my $host = undef;
20 my $port = $ENV{FUMO_PORT} || $ENV{CATALYST_PORT} || 3000;
21 my $keepalive = 0;
22 my $restart = $ENV{FUMO_RELOAD} || $ENV{CATALYST_RELOAD} || 0;
23 my $restart_delay = 1;
24 my $restart_regex = '(?:/|^)(?!\.#).+(?:\.yml$|\.yaml$|\.conf|\.pm)$';
25 my $restart_directory = undef;
26 my $follow_symlinks = 0;
28 my @argv = @ARGV;
30 GetOptions(
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,
44 pod2usage(1) if $help;
46 if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) {
47 $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
49 if ( $debug ) {
50 $ENV{CATALYST_DEBUG} = 1;
53 # This is require instead of use so that the above environment
54 # variables can be set at runtime.
55 require Fumo;
57 Fumo->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 } );
70 =head1 NAME
72 fumo_server.pl - Catalyst Testserver
74 =head1 SYNOPSIS
76 fumo_server.pl [options]
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
101 =head1 DESCRIPTION
103 Run a Catalyst Testserver for this application.
105 =head1 AUTHOR
107 Sebastian Riedel, C<sri@oook.de>
108 Maintained by the Catalyst Core Team.
110 =head1 COPYRIGHT
112 This library is free software, you can redistribute it and/or modify
113 it under the same terms as Perl itself.
115 =cut