working example on ComponentUI
[catagits/Reaction.git] / script / componentui_server.pl
CommitLineData
7adfd53f 1#!/usr/bin/perl -w
2
3BEGIN {
4 $ENV{CATALYST_ENGINE} ||= 'HTTP';
5 $ENV{CATALYST_SCRIPT_GEN} = 28;
6}
7
8use strict;
9use warnings;
10use Getopt::Long;
11use Pod::Usage;
12use FindBin;
13use lib "$FindBin::Bin/../lib";
14
15my $debug = 0;
16my $fork = 0;
17my $help = 0;
18my $host = undef;
19my $port = 3000;
20my $keepalive = 0;
21my $restart = 0;
22my $restart_delay = 1;
23my $restart_regex = '\.yml$|\.yaml$|\.pm$';
24my $restart_directory = undef;
25
26my @argv = @ARGV;
27
28GetOptions(
29 'debug|d' => \$debug,
30 'fork' => \$fork,
31 'help|?' => \$help,
32 'host=s' => \$host,
33 'port=s' => \$port,
34 'keepalive|k' => \$keepalive,
35 'restart|r' => \$restart,
36 'restartdelay|rd=s' => \$restart_delay,
37 'restartregex|rr=s' => \$restart_regex,
38 'restartdirectory=s' => \$restart_directory,
39);
40
41pod2usage(1) if $help;
42
43if ( $restart ) {
44 $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
45}
46if ( $debug ) {
47 $ENV{CATALYST_DEBUG} = 1;
48}
49
50# This is require instead of use so that the above environment
51# variables can be set at runtime.
52require ComponentUI;
53
54ComponentUI->run( $port, $host, {
55 argv => \@argv,
56 'fork' => $fork,
57 keepalive => $keepalive,
58 restart => $restart,
59 restart_delay => $restart_delay,
60 restart_regex => qr/$restart_regex/,
61 restart_directory => $restart_directory,
62} );
63
641;
65
66=head1 NAME
67
68componentui_server.pl - Catalyst Testserver
69
70=head1 SYNOPSIS
71
72componentui_server.pl [options]
73
74 Options:
75 -d -debug force debug mode
76 -f -fork handle each request in a new process
77 (defaults to false)
78 -? -help display this help and exits
79 -host host (defaults to all)
80 -p -port port (defaults to 3000)
81 -k -keepalive enable keep-alive connections
82 -r -restart restart when files get modified
83 (defaults to false)
84 -rd -restartdelay delay between file checks
85 -rr -restartregex regex match files that trigger
86 a restart when modified
87 (defaults to '\.yml$|\.yaml$|\.pm$')
88 -restartdirectory the directory to search for
89 modified files
90 (defaults to '../')
91
92 See also:
93 perldoc Catalyst::Manual
94 perldoc Catalyst::Manual::Intro
95
96=head1 DESCRIPTION
97
98Run a Catalyst Testserver for this application.
99
100=head1 AUTHOR
101
102Sebastian Riedel, C<sri@oook.de>
103Maintained by the Catalyst Core Team.
104
105=head1 COPYRIGHT
106
107This library is free software, you can redistribute it and/or modify
108it under the same terms as Perl itself.
109
110=cut