| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MojoX::Linda; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Plausibly helpful (and probably drunk) wrapper around morbo |
|
3
|
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
481872
|
use 5.022; |
|
|
2
|
|
|
|
|
8
|
|
|
5
|
2
|
|
|
2
|
|
1195
|
use exact; |
|
|
2
|
|
|
|
|
96781
|
|
|
|
2
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
8805
|
use Class::Method::Modifiers 'install_modifier'; |
|
|
2
|
|
|
|
|
4721
|
|
|
|
2
|
|
|
|
|
157
|
|
|
8
|
2
|
|
|
2
|
|
1155
|
use Config::App (); |
|
|
2
|
|
|
|
|
245790
|
|
|
|
2
|
|
|
|
|
296
|
|
|
9
|
2
|
|
|
2
|
|
23
|
use File::Find 'find'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
227
|
|
|
10
|
2
|
|
|
2
|
|
1547
|
use Mojo::Server::Morbo; |
|
|
2
|
|
|
|
|
1445545
|
|
|
|
2
|
|
|
|
|
19
|
|
|
11
|
2
|
|
|
2
|
|
189
|
use Mojo::File 'path'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
4326
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '1.04'; # VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
0
|
399714
|
sub conf ($conf) { |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
3
|
|
|
16
|
1
|
|
|
|
|
16
|
my $conf_app = Config::App->find; |
|
17
|
1
|
50
|
|
|
|
16887
|
my $mojo_linda = ($conf_app) ? $conf_app->get( qw( mojolicious linda ) ) : {}; |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
33
|
|
|
24
|
$conf->{$_} //= $mojo_linda->{$_} for ( qw( silent app production backend ) ); |
|
20
|
1
|
|
33
|
|
|
11
|
$conf->{app} //= $ARGV[0] || do { |
|
|
|
|
33
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $match; |
|
22
|
|
|
|
|
|
|
for my $file ( path('.')->list_tree->to_array->@* ) { |
|
23
|
|
|
|
|
|
|
next unless -x $file; |
|
24
|
|
|
|
|
|
|
if ( $file->slurp =~ /\b( |
|
25
|
|
|
|
|
|
|
Mojolicious::Commands\s*\-\s*>\s*start_app| |
|
26
|
|
|
|
|
|
|
MojoX::ConfigAppStart\s*\-\s*>\s*start |
|
27
|
|
|
|
|
|
|
)\b/x ) { |
|
28
|
|
|
|
|
|
|
$match = $file->to_string; |
|
29
|
|
|
|
|
|
|
last; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
$match; |
|
33
|
|
|
|
|
|
|
}; |
|
34
|
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
3
|
for my $name ( qw( listen watch ) ) { |
|
36
|
2
|
|
|
|
|
13
|
my %hash = map { $_ => 1 } $conf->{$name}->@*, $mojo_linda->{$name}->@*; |
|
|
0
|
|
|
|
|
0
|
|
|
37
|
2
|
|
|
|
|
9
|
$conf->{$name} = [ keys %hash ]; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
1
|
50
|
|
|
|
7
|
unless ( $conf->{listen}->@* ) { |
|
41
|
1
|
|
|
|
|
6
|
for ( 3000 .. 3999 ) { |
|
42
|
1
|
50
|
|
|
|
18
|
unless ( |
|
43
|
|
|
|
|
|
|
IO::Socket::INET->new( |
|
44
|
|
|
|
|
|
|
PeerAddr => 'localhost', |
|
45
|
|
|
|
|
|
|
Proto => 'tcp', |
|
46
|
|
|
|
|
|
|
PeerPort => $_, |
|
47
|
|
|
|
|
|
|
) |
|
48
|
|
|
|
|
|
|
) { |
|
49
|
1
|
|
|
|
|
1552
|
$conf->{listen} = [ 'http://*:' . $_ ]; |
|
50
|
1
|
|
|
|
|
12
|
last; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
1
|
50
|
|
|
|
8
|
$conf_app->deimport if $conf_app; |
|
56
|
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
9
|
return $conf; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
1
|
|
|
1
|
0
|
3
|
sub run ($conf) { |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
2
|
|
|
61
|
1
|
50
|
|
|
|
6
|
$ENV{MOJO_MODE} = 'production' if $conf->{production}; |
|
62
|
1
|
50
|
|
|
|
5
|
$ENV{MOJO_MORBO_BACKEND} = $conf->{backend} if $conf->{backend}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
install_modifier( 'Mojo::Server::Morbo', 'after', '_spawn', sub { |
|
65
|
0
|
0
|
|
0
|
|
0
|
say ' Silent : ', ( ( $conf->{silent} ) ? 'Yes' : 'No' ); |
|
66
|
0
|
|
|
|
|
0
|
say ' App : ', $conf->{app}; |
|
67
|
0
|
|
0
|
|
|
0
|
say ' Mode : ', $ENV{MOJO_MODE} // '>Undefined<'; |
|
68
|
0
|
|
0
|
|
|
0
|
say ' Backend : ', $ENV{MOJO_MORBO_BACKEND} // '>Undefined<'; |
|
69
|
0
|
|
0
|
|
|
0
|
say ' Listen : ', join( ', ', $conf->{listen}->@* ) || '>Unspecified<'; |
|
70
|
0
|
|
0
|
|
|
0
|
say ' Watch : ', join( ', ', $conf->{watch}->@* ) || '>Unspecified<'; |
|
71
|
1
|
50
|
|
|
|
19
|
} ) if ( not $conf->{silent} ); |
|
72
|
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
601
|
my $morbo = Mojo::Server::Morbo->new( silent => $conf->{silent} ); |
|
74
|
|
|
|
|
|
|
|
|
75
|
1
|
50
|
|
|
|
15
|
$morbo->daemon->listen( $conf->{listen} ) if @{ $conf->{listen} }; |
|
|
1
|
|
|
|
|
11
|
|
|
76
|
1
|
50
|
|
|
|
143
|
$morbo->backend->watch( $conf->{watch} ) if @{ $conf->{watch} }; |
|
|
1
|
|
|
|
|
7
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
10
|
$morbo->run( $conf->{app} ); |
|
79
|
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
13
|
return 0; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |