line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Clustericious::Command::hypnotoad; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
565
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
4
|
use Clustericious; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
6
|
1
|
|
|
1
|
|
4
|
use Clustericious::App; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
18
|
use Clustericious::Log; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
877
|
use Mojo::Server::Hypnotoad; |
|
1
|
|
|
|
|
3599
|
|
|
1
|
|
|
|
|
8
|
|
9
|
1
|
|
|
1
|
|
32
|
use base 'Clustericious::Command'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
365
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Clustericious command to stat Hypnotoad |
12
|
|
|
|
|
|
|
our $VERSION = '1.27'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__PACKAGE__->attr(description => "Start a hypnotad web server.\n"); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
__PACKAGE__->attr(usage => <<EOT); |
18
|
|
|
|
|
|
|
Usage $0: hypnotoad |
19
|
|
|
|
|
|
|
No options are available. The 'hypnotoad' entry in the config file |
20
|
|
|
|
|
|
|
is used for configuration. |
21
|
|
|
|
|
|
|
EOT |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub run { |
24
|
0
|
|
|
0
|
1
|
|
my($self, @args) = @_; |
25
|
0
|
|
|
|
|
|
my $conf = $self->app->config->hypnotoad; |
26
|
0
|
|
|
|
|
|
my $exe = $0; |
27
|
0
|
|
|
|
|
|
DEBUG "Running hypnotoad : $exe"; |
28
|
0
|
|
|
|
|
|
$ENV{HYPNOTOAD_EXE} = "$0"; |
29
|
0
|
|
|
|
|
|
my $sentinel = '/no/such/file/because/these/are/deprecated'; |
30
|
0
|
0
|
0
|
|
|
|
if ( $ENV{HYPNOTOAD_CONFIG} && $ENV{HYPNOTOAD_CONFIG} ne $sentinel ) { |
31
|
0
|
|
|
|
|
|
WARN "HYPNOTOAD_CONFIG value $ENV{HYPNOTOAD_CONFIG} will be ignored"; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
# During deprecation, this value must be defined but not pass the -r test |
34
|
|
|
|
|
|
|
# to avoid warnings. |
35
|
0
|
|
|
|
|
|
my $pid = fork(); |
36
|
0
|
0
|
|
|
|
|
if (!defined($pid)) { |
37
|
0
|
|
|
|
|
|
LOGDIE "Unable to fork"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
unless ($pid) { |
41
|
0
|
|
|
|
|
|
DEBUG "Child process $$"; |
42
|
0
|
|
|
|
|
|
local $ENV{HYPNOTOAD_CONFIG} = $sentinel; |
43
|
0
|
|
|
|
|
|
my $pid_file = $conf->{pid_file}; |
44
|
0
|
0
|
|
|
|
|
if (-e $pid_file) { |
45
|
0
|
|
|
|
|
|
chomp (my $pid = Clustericious::_slurp_pid $pid_file); |
46
|
0
|
0
|
|
|
|
|
if (!kill 0, $pid) { |
47
|
0
|
|
|
|
|
|
WARN "removing old pid file $pid_file"; |
48
|
0
|
0
|
|
|
|
|
unlink $pid_file or WARN "Could not remove $pid_file : $!"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
|
my $toad = Mojo::Server::Hypnotoad->new; |
52
|
0
|
|
|
|
|
|
$ENV{CLUSTERICIOUS_COMMAND_NAME} = 'hypnotoad'; |
53
|
0
|
|
|
|
|
|
$toad->run($exe); |
54
|
0
|
|
|
|
|
|
WARN "hypnotoad exited"; |
55
|
0
|
|
|
|
|
|
exit; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
# TODO: see if we can get away without |
58
|
|
|
|
|
|
|
# using this sleep... it would speed up |
59
|
|
|
|
|
|
|
# the test suite a lot. |
60
|
0
|
|
|
|
|
|
sleep 1; |
61
|
0
|
|
|
|
|
|
return 1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=encoding UTF-8 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Clustericious::Command::hypnotoad - Clustericious command to stat Hypnotoad |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 VERSION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
version 1.27 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Start a hypnotoad web server. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Configuration for the server is taken directly from the |
85
|
|
|
|
|
|
|
"hypnotoad" entry in the config file, and turned into |
86
|
|
|
|
|
|
|
a config file for hypnotoad. Among other options in |
87
|
|
|
|
|
|
|
this section these are recognized: |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item listen |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
List of URLS to listen on |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item pid_file |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The location of the PID file. For the stop command to |
98
|
|
|
|
|
|
|
work this MUST be specified., |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 EXAMPLES |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 hypnotoad by itself |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Create a hypnotoad.conf: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
--- |
109
|
|
|
|
|
|
|
% my $root = dir "@{[ home ]}/var/run/"; |
110
|
|
|
|
|
|
|
% $root->mkpath(0,0700); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
url: http://<%= $host %>:<%= $port %> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
start_mode: hypnotoad |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
hypnotoad: |
117
|
|
|
|
|
|
|
listen: |
118
|
|
|
|
|
|
|
- http://<%= $host %>:<%= $port %> |
119
|
|
|
|
|
|
|
pid_file: <%= $root %>/hypnotoad.<%= $port %>.pid |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Then call from your application's config file: |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
--- |
124
|
|
|
|
|
|
|
% extend_config 'hypnotoad', host => 'localhost', port => 3001; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 paired with another server |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Examples for proxying another server to a hypnotoad back end |
129
|
|
|
|
|
|
|
can be found in L<Clustericious::Command::apache> and |
130
|
|
|
|
|
|
|
L<Clustericious::Command::nginx>. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SEE ALSO |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L<Clustericious> |
135
|
|
|
|
|
|
|
L<Mojo::Server::Hypnotoad>, |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Original author: Brian Duggan |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Current maintainer: Graham Ollis E<lt>plicease@cpan.orgE<gt> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Contributors: |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Curt Tilmes |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Yanick Champoux |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This software is copyright (c) 2013 by NASA GSFC. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
154
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |