Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 105 lines (77 sloc) 2.398 kB
ef34b96 initial checkin of in-development perlbal
bradfitz authored
1 #!/usr/bin/perl -w
2 #
0ff3add add a Makefile.PL
bradfitz authored
3
4 =head1 NAME
5
6 Perlbal - Reverse-proxy load balancer and webserver
7
8 =head1 DESCRIPTION
9
18b6b4c improve ... perldoc... slightly.
dormando authored
10 For now, see example configuration files in conf/ from the CPAN tarball
11
12 http://search.cpan.org/dist/Perlbal/
0ff3add add a Makefile.PL
bradfitz authored
13
14 =head1 AUTHORS
15
16 Brad Fitzpatrick, <brad@danga.com>
17 Mark Smith, <marksmith@danga.com>
18
19 =head1 SEE ALSO
20
21 http://www.danga.com/perlbal/
22
3daa078 add copyright notices throughout
bradfitz authored
23 =head1 COPYRIGHT AND LICENSE
0ff3add add a Makefile.PL
bradfitz authored
24
9429e61 Bump copyright and fixed typo in Interactive
jacques authored
25 Copyright 2004, Danga Interactive, Inc.
26 Copyright 2005-2007, Six Apart, Ltd.
0ff3add add a Makefile.PL
bradfitz authored
27
28 You can use and redistribute Perlbal under the same terms as Perl itself.
29
30 =cut
31
ef34b96 initial checkin of in-development perlbal
bradfitz authored
32
33 use strict;
22f5131 Add 'use warnings;' to every perlbal file. Woot.
marksmith authored
34 use warnings;
b164631 break into separate files
bradfitz authored
35 use lib 'lib';
1e4ec91 split front-end and configuration
bradfitz authored
36 use Perlbal;
b164631 break into separate files
bradfitz authored
37
38 my $opt_daemonize;
39 my $opt_config;
9dd8d3d -- new --version and --help flags. also a usage message on bogus
bradfitz authored
40 my $opt_help;
41 my $opt_version;
42 usage(1) unless
b164631 break into separate files
bradfitz authored
43 Getopt::Long::GetOptions(
9dd8d3d -- new --version and --help flags. also a usage message on bogus
bradfitz authored
44 'daemon' => \$opt_daemonize,
45 'config=s' => \$opt_config,
46 'help' => \$opt_help,
47 'version' => \$opt_version,
2b82da3 - Tab fix + local var settings.
deveiant authored
48 );
b164631 break into separate files
bradfitz authored
49
50 my $default_config = "/etc/perlbal/perlbal.conf";
51 $opt_config = $default_config if ! $opt_config && -e $default_config;
52
9dd8d3d -- new --version and --help flags. also a usage message on bogus
bradfitz authored
53 usage(0) if $opt_help;
54
55 sub usage {
56 my $rv = shift;
57 print STDERR <<USAGE;
58 Usage: perlbal [OPTS]
59 --help This usage info
60 --version Print perlbal release version
61 --config=[file] Specify Perlbal config file
62 (default: /etc/perlbal/perlbal.conf)
63 --daemon Daemonize
64 USAGE
65
66 exit($rv);
67 }
68
69 if ($opt_version) {
9356c7e +1.44: 2006-08-09
bradfitz authored
70 print STDOUT "Perlbal version $Perlbal::VERSION\n";
9dd8d3d -- new --version and --help flags. also a usage message on bogus
bradfitz authored
71 exit 0;
72 }
73
b164631 break into separate files
bradfitz authored
74 # load user config
9a6917c error is in $_[0]
bradfitz authored
75 if ($opt_config && ! Perlbal::load_config($opt_config, sub { print STDOUT "$_[0]\n"; })) {
ef59470 rate and time tests
bradfitz authored
76 die "Error starting up.\n";
97ce1ab -- exit with 0 vs non-zero when/if Perlbal crashes. new command
bradfitz authored
77 }
b164631 break into separate files
bradfitz authored
78
ef59470 rate and time tests
bradfitz authored
79 # FIXME: warn harder if web_server services are enabled
0cb1da3 add "none" support to Perlbal::AIO, and warning when using none, and …
bradfitz authored
80 if ($Perlbal::AIO_MODE eq "none") {
81 print STDERR "WARNING: AIO mode disabled or not available. \n".
82 " Perlbal will run slowly under load if you're doing any\n".
9dfff2e more helpful message
bradfitz authored
83 " disk operations. (e.g. web_server mode).\n".
84 " Install IO::AIO for better performance.\n";
0cb1da3 add "none" support to Perlbal::AIO, and warning when using none, and …
bradfitz authored
85 }
86
64c70f1 - Modified to work with updated Perlbal::Socket.
deveiant authored
87 unless (Perlbal::Socket->WatchedSockets() > 0) {
b164631 break into separate files
bradfitz authored
88 die "No services or management port configured. Nothing to do. Stopping.\n";
89 }
90
90ec5a0 daemonization support and start of other server config stuff (max con…
bradfitz authored
91 if ($opt_daemonize) {
1e4ec91 split front-end and configuration
bradfitz authored
92 Perlbal::daemonize();
90ec5a0 daemonization support and start of other server config stuff (max con…
bradfitz authored
93 } else {
94 print "Running.\n";
95 }
b164631 break into separate files
bradfitz authored
96
97ce1ab -- exit with 0 vs non-zero when/if Perlbal crashes. new command
bradfitz authored
97 exit 0 if Perlbal::run();
98 exit 1;
2b82da3 - Tab fix + local var settings.
deveiant authored
99
100 # Local Variables:
101 # mode: perl
102 # c-basic-indent: 4
103 # indent-tabs-mode: nil
104 # End:
Something went wrong with that request. Please try again.