| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Clustericious::Command::apache; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
818
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use Clustericious::App; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
1
|
|
|
1
|
|
19
|
use base 'Clustericious::Command'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
80
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use File::Which qw( which ); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
197
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Clustericious command to stat Apache |
|
10
|
|
|
|
|
|
|
our $VERSION = '1.27'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->attr(description => <<EOT); |
|
14
|
|
|
|
|
|
|
Start an Apache web server. |
|
15
|
|
|
|
|
|
|
EOT |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
__PACKAGE__->attr(usage => <<EOT); |
|
18
|
|
|
|
|
|
|
Usage $0: Apache -f <conf> [...other Apache options] |
|
19
|
|
|
|
|
|
|
Starts an Apache webserver. |
|
20
|
|
|
|
|
|
|
Options are passed verbatim to the httpd executable. |
|
21
|
|
|
|
|
|
|
EOT |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub run { |
|
24
|
0
|
|
|
0
|
1
|
|
my($self, @args) = @_; |
|
25
|
0
|
|
|
|
|
|
$self->app->init_logging; |
|
26
|
0
|
|
0
|
|
|
|
my $command = which('httpd') || die "unable to find apache"; |
|
27
|
0
|
|
|
|
|
|
system $command, @args; |
|
28
|
0
|
0
|
|
|
|
|
die "'$command @args' Failed to execute: $!" if $? == -1; |
|
29
|
0
|
0
|
|
|
|
|
die "'$command @args' Killed with signal: ", $? & 127 if $? & 127; |
|
30
|
0
|
0
|
|
|
|
|
die "'$command @args' Exited with ", $? >> 8 if $? >> 8; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=encoding UTF-8 |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Clustericious::Command::apache - Clustericious command to stat Apache |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 VERSION |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
version 1.27 |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Start an Apache web server. The Apache start and stop commands recognize these options |
|
52
|
|
|
|
|
|
|
in their configuration section: |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over 4 |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item pid_file |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
The location to the pid file. This should usually be the same as the C<PidFile> directive |
|
59
|
|
|
|
|
|
|
in your Apache configuration. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=back |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 EXAMPLES |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
These examples are for Apache 2.4. Getting them to work on Apache |
|
66
|
|
|
|
|
|
|
2.2 will require some tweaking. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 mod_proxy with hypnotoad |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Create a apache24-proxy.conf: |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
--- |
|
73
|
|
|
|
|
|
|
% my $root = dir "@{[ home ]}/var/run"; |
|
74
|
|
|
|
|
|
|
% $root->mkpath(0,0700); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
url: http://<%= $host %>:<%= $port %> |
|
77
|
|
|
|
|
|
|
start_mode: |
|
78
|
|
|
|
|
|
|
- hypnotoad |
|
79
|
|
|
|
|
|
|
- apache |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
apache: |
|
82
|
|
|
|
|
|
|
args: -f <%= $root %>/apache.<%= $port %>.conf -E <%= $root %>/apache.<%= $port %>.startup.log |
|
83
|
|
|
|
|
|
|
pid_file: <%= $root %>/apache.<%= $port %>.pid |
|
84
|
|
|
|
|
|
|
autogen: |
|
85
|
|
|
|
|
|
|
filename: <%= $root %>/apache.<%= $port %>.conf |
|
86
|
|
|
|
|
|
|
content: | |
|
87
|
|
|
|
|
|
|
LoadModule unixd_module modules/mod_unixd.so |
|
88
|
|
|
|
|
|
|
LoadModule headers_module modules/mod_headers.so |
|
89
|
|
|
|
|
|
|
LoadModule proxy_module modules/mod_proxy.so |
|
90
|
|
|
|
|
|
|
LoadModule proxy_http_module modules/mod_proxy_http.so |
|
91
|
|
|
|
|
|
|
LoadModule authn_core_module modules/mod_authn_core.so |
|
92
|
|
|
|
|
|
|
LoadModule authz_core_module modules/mod_authz_core.so |
|
93
|
|
|
|
|
|
|
LoadModule authz_host_module modules/mod_authz_host.so |
|
94
|
|
|
|
|
|
|
LoadModule log_config_module modules/mod_log_config.so |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Listen <%= $host %>:<%= $port %> |
|
97
|
|
|
|
|
|
|
ServerName <%= $host %> |
|
98
|
|
|
|
|
|
|
PidFile <%= $root %>/apache.<%= $port %>.pid |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
ErrorLog <%= $root %>/apache.<%= $port %>.error.log |
|
101
|
|
|
|
|
|
|
LogFormat "%h %l %u %t \"%r\" %>s %b" common |
|
102
|
|
|
|
|
|
|
CustomLog <%= $root %>/apache.<%= $port %>.access.log common |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
<Location /> |
|
105
|
|
|
|
|
|
|
ProxyPreserveHost On |
|
106
|
|
|
|
|
|
|
ProxyPass http://localhost:<%= $port %>/ |
|
107
|
|
|
|
|
|
|
ProxyPassReverse http://localhost:<%= $port %>/ |
|
108
|
|
|
|
|
|
|
RequestHeader append set X-Forward-Proto |
|
109
|
|
|
|
|
|
|
<RequireAll> |
|
110
|
|
|
|
|
|
|
Require all granted |
|
111
|
|
|
|
|
|
|
</RequireAll> |
|
112
|
|
|
|
|
|
|
</Location> |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
hypnotoad: |
|
115
|
|
|
|
|
|
|
listen: |
|
116
|
|
|
|
|
|
|
- http://127.0.0.1:<%= $port %> |
|
117
|
|
|
|
|
|
|
pid_file: <%= $root %>/hypnotoad.<%= $port %>.pid |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Note that this configuration binds hypnotoad to C<localhost> and |
|
120
|
|
|
|
|
|
|
Apache to the IP that you pass in. Then call from your application's |
|
121
|
|
|
|
|
|
|
config file: |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
--- |
|
124
|
|
|
|
|
|
|
# If hostname() (should be the same as what the command hostname |
|
125
|
|
|
|
|
|
|
# prints) is not a valid address that you can bind to, or if |
|
126
|
|
|
|
|
|
|
# your hostname is the IP as localhost, then change the host to |
|
127
|
|
|
|
|
|
|
# a literal IP address |
|
128
|
|
|
|
|
|
|
% extend_config 'apache24-proxy', host => hostname(), port => 3001; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 CGI |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
CGI is not recommends, for reasons that are hopefully obvious. It does |
|
133
|
|
|
|
|
|
|
allow you to run Clustericious from |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Create a apache24-cgi.conf: |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
--- |
|
138
|
|
|
|
|
|
|
% my $root = dir "@{[ home ]}/var/run"; |
|
139
|
|
|
|
|
|
|
% $root->mkpath(0,0700); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
url: http://<%= $host %>:<%= $port %> |
|
142
|
|
|
|
|
|
|
start_mode: apache |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
apache: |
|
145
|
|
|
|
|
|
|
args: -f <%= $root %>/apache.<%= $port %>.conf -E <%= $root %>/apache.<%= $port %>.startup.log |
|
146
|
|
|
|
|
|
|
pid_file: <%= $root %>/apache.<%= $port %>.pid |
|
147
|
|
|
|
|
|
|
autogen: |
|
148
|
|
|
|
|
|
|
filename: <%= $root %>/apache.<%= $port %>.conf |
|
149
|
|
|
|
|
|
|
content: | |
|
150
|
|
|
|
|
|
|
LoadModule alias_module modules/mod_alias.so |
|
151
|
|
|
|
|
|
|
LoadModule cgi_module modules/mod_cgi.so |
|
152
|
|
|
|
|
|
|
LoadModule unixd_module modules/mod_unixd.so |
|
153
|
|
|
|
|
|
|
LoadModule authn_core_module modules/mod_authn_core.so |
|
154
|
|
|
|
|
|
|
LoadModule authz_core_module modules/mod_authz_core.so |
|
155
|
|
|
|
|
|
|
LoadModule authz_host_module modules/mod_authz_host.so |
|
156
|
|
|
|
|
|
|
LoadModule env_module modules/mod_env.so |
|
157
|
|
|
|
|
|
|
LoadModule log_config_module modules/mod_log_config.so |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Listen <%= $host %>:<%= $port %> |
|
160
|
|
|
|
|
|
|
ServerName <%= $host %> |
|
161
|
|
|
|
|
|
|
PidFile <%= $root %>/apache.<%= $port %>.pid |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
ErrorLog <%= $root %>/apache.<%= $port %>.error.log |
|
164
|
|
|
|
|
|
|
LogFormat "%h %l %u %t \"%r\" %>s %b" common |
|
165
|
|
|
|
|
|
|
CustomLog <%= $root %>/apache.<%= $port %>.access.log common |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
PassEnv PERL5LIB |
|
168
|
|
|
|
|
|
|
PassEnv HOME |
|
169
|
|
|
|
|
|
|
ScriptAlias / <%= $0 %>/ |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
<Directory <%= $0 %>/ > |
|
172
|
|
|
|
|
|
|
Options +ExecCGI |
|
173
|
|
|
|
|
|
|
SetHandler cgi-script |
|
174
|
|
|
|
|
|
|
<RequireAll> |
|
175
|
|
|
|
|
|
|
Require all granted |
|
176
|
|
|
|
|
|
|
</RequireAll> |
|
177
|
|
|
|
|
|
|
</Directory> |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Then call from your application's config file: |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
--- |
|
183
|
|
|
|
|
|
|
% extend_config 'apache24-cgi', host => 'localhost', port => 3001; |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
L<Clustericious> |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 AUTHOR |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Original author: Brian Duggan |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Current maintainer: Graham Ollis E<lt>plicease@cpan.orgE<gt> |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Contributors: |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Curt Tilmes |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Yanick Champoux |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This software is copyright (c) 2013 by NASA GSFC. |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
206
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=cut |