source: trunk/LATMOS-Accounts-Web/script/latmos_accounts_web_server.pl @ 2103

Last change on this file since 2103 was 1539, checked in by nanardon, 8 years ago

Revert "remove -w (redundant with use warnings"

This reverts commit ee3b755ce135ec47fee59b5edd3d7c67d4141189.

  • Property svn:executable set to *
File size: 3.2 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 $daemon            = 0;
18my $fork              = 0;
19my $help              = 0;
20my $host              = undef;
21my $port              = 3000;
22my $keepalive         = 0;
23my $restart           = 0;
24my $restart_delay     = 1;
25my $restart_regex     = '\.yml$|\.yaml$|\.pm$';
26my $restart_directory = undef;
27my $forcehttps        = 0;
28
29my @argv = @ARGV;
30
31GetOptions(
32    'debug|d'             => \$debug,
33    'fork'                => \$fork,
34    'daemon'              => \$daemon,
35    'help|?'              => \$help,
36    'host=s'              => \$host,
37    'port=s'              => \$port,
38    'keepalive|k'         => \$keepalive,
39    'restart|r'           => \$restart,
40    'restartdelay|rd=s'   => \$restart_delay,
41    'restartregex|rr=s'   => \$restart_regex,
42    'restartdirectory=s'  => \$restart_directory,
43    'forcehttps'          => \$forcehttps,
44);
45
46pod2usage(1) if $help;
47
48if ( $restart ) {
49    $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
50}
51if ( $debug ) {
52    $ENV{CATALYST_DEBUG} = 1;
53}
54if ( $forcehttps ) {
55    $ENV{HTTPS} = 'ON';
56}
57
58if ($daemon) {
59    require POSIX;
60    my $childpid = fork;
61    if ($childpid) {
62       exit(0);
63    }
64    # child now
65    open STDIN,  "+</dev/null" or die $!;
66    open STDOUT, ">&STDIN"     or die $!;
67    open STDERR, ">&STDIN"     or die $!;
68}
69
70# This is require instead of use so that the above environment
71# variables can be set at runtime.
72require LATMOS::Accounts::Web;
73
74LATMOS::Accounts::Web->run( $port, $host, {
75    argv              => \@argv,
76    'fork'            => $fork,
77    keepalive         => $keepalive,
78    restart           => $restart,
79    restart_delay     => $restart_delay,
80    restart_regex     => qr/$restart_regex/,
81    restart_directory => $restart_directory,
82} );
83
841;
85
86=head1 NAME
87
88latmos_accounts_web_server.pl - Catalyst Testserver
89
90=head1 SYNOPSIS
91
92latmos_accounts_web_server.pl [options]
93
94 Options:
95   -d -debug          force debug mode
96   -f -fork           handle each request in a new process
97                      (defaults to false)
98   -? -help           display this help and exits
99      -host           host (defaults to all)
100   -p -port           port (defaults to 3000)
101   -k -keepalive      enable keep-alive connections
102   -r -restart        restart when files get modified
103                      (defaults to false)
104   -rd -restartdelay  delay between file checks
105   -rr -restartregex  regex match files that trigger
106                      a restart when modified
107                      (defaults to '\.yml$|\.yaml$|\.pm$')
108   -restartdirectory  the directory to search for
109                      modified files
110                      (defaults to '../')
111   -forcehttps        force url to https
112
113 See also:
114   perldoc Catalyst::Manual
115   perldoc Catalyst::Manual::Intro
116
117=head1 DESCRIPTION
118
119Run a Catalyst Testserver for this application.
120
121=head1 AUTHOR
122
123Sebastian Riedel, C<sri@oook.de>
124Maintained by the Catalyst Core Team.
125
126=head1 COPYRIGHT
127
128This library is free software, you can redistribute it and/or modify
129it under the same terms as Perl itself.
130
131=cut
Note: See TracBrowser for help on using the repository browser.