root/lang/perl/Server-Starter/trunk/start_server @ 35270

Revision 35270, 1.7 kB (checked in by kazuho, 5 years ago)

pod! pod! pod!

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