line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Clustericious::Command::start; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
651
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
6
|
use Clustericious::Log; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
621
|
use File::Path qw( mkpath ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
7
|
1
|
|
|
1
|
|
6
|
use File::Basename qw( dirname ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
8
|
1
|
|
|
1
|
|
5
|
use Clustericious::App; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
22
|
use Clustericious::Config; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
10
|
1
|
|
|
1
|
|
4
|
use Mojo::Base 'Clustericious::Command'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
11
|
1
|
|
|
1
|
|
381
|
use Text::ParseWords qw( shellwords ); |
|
1
|
|
|
|
|
957
|
|
|
1
|
|
|
|
|
48
|
|
12
|
1
|
|
|
1
|
|
7
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
13
|
1
|
|
|
1
|
|
600
|
use Env qw( @PERL5LIB ); |
|
1
|
|
|
|
|
1797
|
|
|
1
|
|
|
|
|
6
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ABSTRACT: Clustericious command to start a Clustericious application |
16
|
|
|
|
|
|
|
our $VERSION = '1.27'; # VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has description => <<EOT; |
20
|
|
|
|
|
|
|
Start a daemon using the config file. |
21
|
|
|
|
|
|
|
EOT |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has usage => <<EOT; |
24
|
|
|
|
|
|
|
usage $0: start |
25
|
|
|
|
|
|
|
Start a daemon using the start_mode in the config file. |
26
|
|
|
|
|
|
|
See Clustericious::Config for the format of the config file. |
27
|
|
|
|
|
|
|
See Clustericious::Command::Start for examples. |
28
|
|
|
|
|
|
|
EOT |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub run { |
31
|
0
|
|
|
0
|
1
|
|
my($self, @args) = @_; |
32
|
0
|
0
|
|
|
|
|
exit 2 unless $self->app->sanity_check; |
33
|
0
|
|
|
|
|
|
my $app = $ENV{MOJO_APP}; |
34
|
0
|
|
|
|
|
|
my $conf = $self->app->config; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
eval "use $app;"; |
37
|
0
|
0
|
|
|
|
|
die $@ if $@; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$self->app->init_logging; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
for my $mode ($self->app->config->start_mode) |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
|
|
|
INFO "Starting $mode"; |
44
|
0
|
|
|
|
|
|
my %conf = $conf->$mode; |
45
|
0
|
0
|
|
|
|
|
if(my $autogen = delete $conf{autogen}) |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
0
|
|
|
|
|
$autogen = [ $autogen ] if ref $autogen eq 'HASH'; |
48
|
0
|
|
|
|
|
|
for my $i (@$autogen) |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
|
|
|
|
|
DEBUG "autowriting ".$i->{filename}; |
51
|
0
|
|
|
|
|
|
mkpath(dirname($i->{filename}), 0, 0700); |
52
|
0
|
0
|
|
|
|
|
open my $fp, ">$i->{filename}" or LOGDIE "cannot write to $i->{filename} : $!"; |
53
|
0
|
|
|
|
|
|
print $fp $i->{content}; |
54
|
0
|
0
|
|
|
|
|
close $fp or LOGDIE $!; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# env hash goes to the environment |
59
|
0
|
|
0
|
|
|
|
my $env = delete $conf{env} || {}; |
60
|
0
|
|
|
|
|
|
@ENV{ keys %$env } = values %$env; |
61
|
0
|
0
|
|
|
|
|
if($env->{PERL5LIB}) |
62
|
|
|
|
|
|
|
{ |
63
|
|
|
|
|
|
|
# Do it now, in case we are not spawning a new process. |
64
|
0
|
|
|
|
|
|
push @INC, @PERL5LIB; |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
|
TRACE "Setting env vars : ".join ',', keys %$env; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my @args; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
if(my $args = delete $conf{args}) |
|
|
0
|
|
|
|
|
|
71
|
|
|
|
|
|
|
{ |
72
|
0
|
0
|
|
|
|
|
@args = ref $args ne 'ARRAY' ? (shellwords $args) : @$args; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
elsif(%conf) |
75
|
|
|
|
|
|
|
{ |
76
|
0
|
|
|
|
|
|
die "arguments specified withouth 'args' option\n"; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
DEBUG "Sending args for $mode : @args"; |
80
|
0
|
|
|
|
|
|
$ENV{MOJO_COMMANDS_DONE} = 0; |
81
|
0
|
|
|
|
|
|
Clustericious::Commands->start($mode,@args); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=encoding UTF-8 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Clustericious::Command::start - Clustericious command to start a Clustericious application |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 VERSION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
version 1.27 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SYNOPSIS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
In your MyApp.conf: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
--- |
106
|
|
|
|
|
|
|
start_mode: hypnotoad |
107
|
|
|
|
|
|
|
hypnotoad: |
108
|
|
|
|
|
|
|
pid: /tmp/restmd.pid |
109
|
|
|
|
|
|
|
[...] |
110
|
|
|
|
|
|
|
env: |
111
|
|
|
|
|
|
|
foo: bar |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Then on the command line |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
% myapp start |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Which is equivalent to |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
% foo=bar myapp hypnotoad --pid /tmp/restmd.pid [..] |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DESCRIPTION |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Start a daemon using the config file and the start_mode. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Keys and values in the configuration file become |
126
|
|
|
|
|
|
|
options preceded by double dashes. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
If a key has a single dash, it is sent as is (with no double dash). |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
The special value C<null> means don't send an argument to the |
131
|
|
|
|
|
|
|
command line option. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The special label C<env> is an optional hash of environment variables |
134
|
|
|
|
|
|
|
to set before starting the command. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 NAME |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Clustericious::Command::start - Clustericious command to start a Clustericious application |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 SEE ALSO |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<Clustericious>, |
143
|
|
|
|
|
|
|
L<Clustericious::Command::hypnotoad> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Original author: Brian Duggan |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Current maintainer: Graham Ollis E<lt>plicease@cpan.orgE<gt> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Contributors: |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Curt Tilmes |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Yanick Champoux |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This software is copyright (c) 2013 by NASA GSFC. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
162
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |