blib/lib/auto/share/dist/Amon2/flavor/Minimum/script/server.pl untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod n/a totaltotal 0.0% 0 / 82 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!perl
2 use strict;
3 use warnings;
4 use utf8;
5 use File::Spec;
6 use File::Basename;
7 use lib File::Spec->catdir(dirname(__FILE__), '../lib');
8 use Plack::Builder;
9  
10 %% block load_modules -> {
11 use <% $module %>::Web;
12 %% }
13  
14 %% block app -> {
15 my $app = builder {
16 enable 'Plack::Middleware::AccessLog';
17 enable 'Plack::Middleware::Static',
18 path => qr{^(?:/static/)},
19 root => File::Spec->catdir(dirname(__FILE__), '..');
20 enable 'Plack::Middleware::Static',
21 path => qr{^(?:/robots\.txt|/favicon\.ico)$},
22 root => File::Spec->catdir(dirname(__FILE__), '..', 'static');
23 <% $module %>::Web->to_app();
24 };
25 %% }
26 unless (caller) {
27 my $port = 5000;
28 my $host = '127.0.0.1';
29 my $max_workers = 4;
30  
31 require Getopt::Long;
32 require Plack::Loader;
33 my $p = Getopt::Long::Parser->new(
34 config => [qw(posix_default no_ignore_case auto_help)]
35 );
36 $p->getoptions(
37 'p|port=i' => \$port,
38 'host=s' => \$host,
39 'max-workers=i' => \$max_workers,
40 'version!' => \my $version,
41 'c|config=s' => \my $config_file,
42 );
43 if ($version) {
44 print "<% $module %>: $<% $module %>::VERSION\n";
45 exit 0;
46 }
47 if ($config_file) {
48 my $config = do $config_file;
49 Carp::croak("$config_file: $@") if $@;
50 Carp::croak("$config_file: $!") unless defined $config;
51 unless ( ref($config) eq 'HASH' ) {
52 Carp::croak("$config_file does not return HashRef.");
53 }
54 no warnings 'redefine';
55 no warnings 'once';
56 *<% $module %>::load_config = sub { $config }
57 }
58  
59 print "<% $module %>: http://${host}:${port}/\n";
60  
61 my $loader = Plack::Loader->load('Starlet',
62 port => $port,
63 host => $host,
64 max_workers => $max_workers,
65 );
66 return $loader->run($app);
67 }
68 return $app;