source: trunk/Vote/script/vote_server.pl @ 2

Last change on this file since 2 was 2, checked in by nanardon, 15 years ago
  • create with catalyst
  • Property svn:executable set to *
File size: 2.7 KB
Line 
1#!/usr/bin/perl -w
2
3BEGIN { 
4    $ENV{CATALYST_ENGINE} ||= 'HTTP';
5    $ENV{CATALYST_SCRIPT_GEN} = 30;
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              = 3000;
21my $keepalive         = 0;
22my $restart           = 0;
23my $restart_delay     = 1;
24my $restart_regex     = '\.yml$|\.yaml$|\.pm$';
25my $restart_directory = undef;
26
27my @argv = @ARGV;
28
29GetOptions(
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
42pod2usage(1) if $help;
43
44if ( $restart ) {
45    $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
46}
47if ( $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.
53require Vote;
54
55Vote->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
651;
66
67=head1 NAME
68
69vote_server.pl - Catalyst Testserver
70
71=head1 SYNOPSIS
72
73vote_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
99Run a Catalyst Testserver for this application.
100
101=head1 AUTHOR
102
103Sebastian Riedel, C<sri@oook.de>
104Maintained by the Catalyst Core Team.
105
106=head1 COPYRIGHT
107
108This library is free software, you can redistribute it and/or modify
109it under the same terms as Perl itself.
110
111=cut
Note: See TracBrowser for help on using the repository browser.