|
Revision 35270, 1.7 kB
(checked in by kazuho, 4 years ago)
|
|
pod! pod! pod!
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #! /usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | |
|---|
| 6 | use Getopt::Long; |
|---|
| 7 | use Server::Starter qw(start_server); |
|---|
| 8 | |
|---|
| 9 | sub usage { |
|---|
| 10 | print <<"EOT"; |
|---|
| 11 | Usage: $0 [options] server-prog server-arg1 server-arg2 ... |
|---|
| 12 | |
|---|
| 13 | Example: |
|---|
| 14 | start_server --port=80 -- my_server |
|---|
| 15 | listen to port 80 and start my_server |
|---|
| 16 | |
|---|
| 17 | Options: |
|---|
| 18 | --port=(port|host:port) TCP port to listen to (should be specified more |
|---|
| 19 | than once) |
|---|
| 20 | --interval=seconds minimum interval to respawn the server process |
|---|
| 21 | (default: 1) |
|---|
| 22 | |
|---|
| 23 | EOT |
|---|
| 24 | exit 0; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | my (@opt_port, $opt_interval, $opt_help, $opt_version); |
|---|
| 28 | |
|---|
| 29 | GetOptions( |
|---|
| 30 | 'port=s' => \@opt_port, |
|---|
| 31 | 'interval=i' => \$opt_interval, |
|---|
| 32 | help => \$opt_help, |
|---|
| 33 | version => \$opt_version, |
|---|
| 34 | ) or exit 1; |
|---|
| 35 | usage() |
|---|
| 36 | if $opt_help; |
|---|
| 37 | if ($opt_version) { |
|---|
| 38 | print "$Server::Starter::VERSION\n"; |
|---|
| 39 | exit 0; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | # validate options |
|---|
| 43 | die "mandatory option --port=port is missing\n" |
|---|
| 44 | unless @opt_port; |
|---|
| 45 | die "server program not specified\n" |
|---|
| 46 | unless @ARGV; |
|---|
| 47 | |
|---|
| 48 | start_server( |
|---|
| 49 | exec => \@ARGV, |
|---|
| 50 | port => \@opt_port, |
|---|
| 51 | ($opt_interval ? (interval => $opt_interval) : ()), |
|---|
| 52 | ); |
|---|
| 53 | |
|---|
| 54 | __END__ |
|---|
| 55 | |
|---|
| 56 | =head1 NAME |
|---|
| 57 | |
|---|
| 58 | start_server - a superdaemon for hot-deploying server programs |
|---|
| 59 | |
|---|
| 60 | =head1 SYNOPSIS |
|---|
| 61 | |
|---|
| 62 | start_server [options] server-prog server-arg1 server-arg2 ... |
|---|
| 63 | |
|---|
| 64 | =head1 DESCRIPTION |
|---|
| 65 | |
|---|
| 66 | This script is a frontend of L<Server::Starter>. For more information please refer to the documenation of the module. |
|---|
| 67 | |
|---|
| 68 | Use --help to find out how to use the script. |
|---|
| 69 | |
|---|
| 70 | =head1 AUTHOR |
|---|
| 71 | |
|---|
| 72 | Kazuho Oku E<lt>kazuhooku@gmail.comE<gt> |
|---|
| 73 | Copyright (C) 2009 Cybozu Labs, Inc. |
|---|
| 74 | |
|---|
| 75 | =head1 SEE ALSO |
|---|
| 76 | |
|---|
| 77 | L<Server::Starter> |
|---|
| 78 | |
|---|
| 79 | =head1 LICENSE |
|---|
| 80 | |
|---|
| 81 | This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
|---|
| 82 | |
|---|
| 83 | =cut |
|---|