[1539] | 1 | #!/usr/bin/perl -w |
---|
[94] | 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; |
---|
[554] | 17 | my $daemon = 0; |
---|
[94] | 18 | my $fork = 0; |
---|
| 19 | my $help = 0; |
---|
| 20 | my $host = undef; |
---|
| 21 | my $port = 3000; |
---|
| 22 | my $keepalive = 0; |
---|
| 23 | my $restart = 0; |
---|
| 24 | my $restart_delay = 1; |
---|
| 25 | my $restart_regex = '\.yml$|\.yaml$|\.pm$'; |
---|
| 26 | my $restart_directory = undef; |
---|
[605] | 27 | my $forcehttps = 0; |
---|
[94] | 28 | |
---|
| 29 | my @argv = @ARGV; |
---|
| 30 | |
---|
| 31 | GetOptions( |
---|
| 32 | 'debug|d' => \$debug, |
---|
| 33 | 'fork' => \$fork, |
---|
[554] | 34 | 'daemon' => \$daemon, |
---|
[94] | 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, |
---|
[605] | 43 | 'forcehttps' => \$forcehttps, |
---|
[94] | 44 | ); |
---|
| 45 | |
---|
| 46 | pod2usage(1) if $help; |
---|
| 47 | |
---|
| 48 | if ( $restart ) { |
---|
| 49 | $ENV{CATALYST_ENGINE} = 'HTTP::Restarter'; |
---|
| 50 | } |
---|
| 51 | if ( $debug ) { |
---|
| 52 | $ENV{CATALYST_DEBUG} = 1; |
---|
| 53 | } |
---|
[605] | 54 | if ( $forcehttps ) { |
---|
| 55 | $ENV{HTTPS} = 'ON'; |
---|
| 56 | } |
---|
[94] | 57 | |
---|
[554] | 58 | if ($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 | |
---|
[94] | 70 | # This is require instead of use so that the above environment |
---|
| 71 | # variables can be set at runtime. |
---|
| 72 | require LATMOS::Accounts::Web; |
---|
| 73 | |
---|
| 74 | LATMOS::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 | |
---|
| 84 | 1; |
---|
| 85 | |
---|
| 86 | =head1 NAME |
---|
| 87 | |
---|
| 88 | latmos_accounts_web_server.pl - Catalyst Testserver |
---|
| 89 | |
---|
| 90 | =head1 SYNOPSIS |
---|
| 91 | |
---|
| 92 | latmos_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 '../') |
---|
[605] | 111 | -forcehttps force url to https |
---|
[94] | 112 | |
---|
| 113 | See also: |
---|
| 114 | perldoc Catalyst::Manual |
---|
| 115 | perldoc Catalyst::Manual::Intro |
---|
| 116 | |
---|
| 117 | =head1 DESCRIPTION |
---|
| 118 | |
---|
| 119 | Run a Catalyst Testserver for this application. |
---|
| 120 | |
---|
| 121 | =head1 AUTHOR |
---|
| 122 | |
---|
| 123 | Sebastian Riedel, C<sri@oook.de> |
---|
| 124 | Maintained by the Catalyst Core Team. |
---|
| 125 | |
---|
| 126 | =head1 COPYRIGHT |
---|
| 127 | |
---|
| 128 | This library is free software, you can redistribute it and/or modify |
---|
| 129 | it under the same terms as Perl itself. |
---|
| 130 | |
---|
| 131 | =cut |
---|