root/docs/holidays-l/RSTGateway/script/rstgateway_server.pl @ 26748

Revision 26748, 3.2 kB (checked in by holidays-l, 6 years ago)

docs/holidays-l/RSTGateway: 3分で作る即興プレゼンアプリ

  • Property svn:executable set to *
Line 
1#!/usr/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{RSTGATEWAY_PORT} || $ENV{CATALYST_PORT} || 3000;
21my $keepalive         = 0;
22my $restart           = $ENV{RSTGATEWAY_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 RSTGateway;
56
57RSTGateway->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
72rstgateway_server.pl - Catalyst Testserver
73
74=head1 SYNOPSIS
75
76rstgateway_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 AUTHOR
106
107Sebastian Riedel, C<sri@oook.de>
108Maintained by the Catalyst Core Team.
109
110=head1 COPYRIGHT
111
112This library is free software, you can redistribute it and/or modify
113it under the same terms as Perl itself.
114
115=cut
Note: See TracBrowser for help on using the browser.