-
Notifications
You must be signed in to change notification settings - Fork 46
/
perlbal
executable file
·104 lines (77 loc) · 2.34 KB
/
perlbal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/perl -w
#
=head1 NAME
Perlbal - Reverse-proxy load balancer and webserver
=head1 DESCRIPTION
For now, see example configuration files in conf/ from the CPAN tarball
http://search.cpan.org/dist/Perlbal/
=head1 AUTHORS
Brad Fitzpatrick, <[email protected]>
Mark Smith, <[email protected]>
=head1 SEE ALSO
http://www.danga.com/perlbal/
=head1 COPYRIGHT AND LICENSE
Copyright 2004, Danga Interactive, Inc.
Copyright 2005-2007, Six Apart, Ltd.
You can use and redistribute Perlbal under the same terms as Perl itself.
=cut
use strict;
use warnings;
use lib 'lib';
use Perlbal;
my $opt_daemonize;
my $opt_config;
my $opt_help;
my $opt_version;
usage(1) unless
Getopt::Long::GetOptions(
'daemon' => \$opt_daemonize,
'config=s' => \$opt_config,
'help' => \$opt_help,
'version' => \$opt_version,
);
my $default_config = "/etc/perlbal/perlbal.conf";
$opt_config = $default_config if ! $opt_config && -e $default_config;
usage(0) if $opt_help;
sub usage {
my $rv = shift;
print STDERR <<USAGE;
Usage: perlbal [OPTS]
--help This usage info
--version Print perlbal release version
--config=[file] Specify Perlbal config file
(default: /etc/perlbal/perlbal.conf)
--daemon Daemonize
USAGE
exit($rv);
}
if ($opt_version) {
print STDOUT "Perlbal version $Perlbal::VERSION\n";
exit 0;
}
# load user config
if ($opt_config && ! Perlbal::load_config($opt_config, sub { print STDOUT "$_[0]\n"; })) {
die "Error starting up.\n";
}
# FIXME: warn harder if web_server services are enabled
if ($Perlbal::AIO_MODE eq "none") {
print STDERR "WARNING: AIO mode disabled or not available. \n".
" Perlbal will run slowly under load if you're doing any\n".
" disk operations. (e.g. web_server mode).\n".
" Install IO::AIO for better performance.\n";
}
unless (Perlbal::Socket->WatchedSockets() > 0) {
die "No services or management port configured. Nothing to do. Stopping.\n";
}
if ($opt_daemonize) {
Perlbal::daemonize();
} else {
print "Running.\n";
}
exit 0 if Perlbal::run();
exit 1;
# Local Variables:
# mode: perl
# c-basic-indent: 4
# indent-tabs-mode: nil
# End: