File Coverage

script/ukigumo-agent
Criterion Covered Total %
statement 30 32 93.7
branch n/a
condition n/a
subroutine 11 11 100.0
pod n/a
total 41 43 95.3


line stmt bran cond sub pod time code
1             #!/usr/bin/env perl
2 1     1   47925 use strict;
  1         4  
  1         141  
3 1     1   20 use warnings;
  1         10  
  1         98  
4 1     1   26 use utf8;
  1         11  
  1         69  
5 1     1   191 use 5.010000;
  1         5  
6 1     1   1624 use autodie;
  1         19906  
  1         6  
7 1     1   7132 use FindBin;
  1         1256  
  1         62  
8 1     1   743 use lib "$FindBin::Bin/../lib";
  1         679  
  1         7  
9              
10 1     1   1023 use Twiggy::Server;
  1         58089  
  1         40  
11 1     1   700 use Plack::Builder;
  1         6815  
  1         87  
12 1     1   700 use Plack::App::File;
  1         2645  
  1         30  
13 1     1   606 use Ukigumo::Agent;
  0            
  0            
14             use Ukigumo::Agent::Manager;
15             use Getopt::Long;
16             use Pod::Usage;
17             use File::Spec;
18              
19             $|++;
20              
21             my $host = '0.0.0.0';
22             my $port = 1984;
23             my $cleanup_cycle = 0;
24              
25             GetOptions(
26             'c|config=s' => \my $file,
27              
28             'h|host=s' => \$host,
29             'p|port=i' => \$port,
30             'cleanup_cycle=i' => \$cleanup_cycle,
31              
32             'work_dir=s' => \my $work_dir,
33             'server_url=s' => \my $server_url,
34             'timeout=i' => \my $timeout,
35             'ignore_github_tags' => \my $ignore_github_tags,
36             'force_git_url' => \my $force_git_url,
37             );
38              
39             my $config = ($file && -f $file) ? Ukigumo::Agent->load_config($file) : +{};
40              
41             $config->{work_dir} = $work_dir if defined $work_dir;
42             $config->{server_url} = $server_url if defined $server_url;
43             $config->{timeout} = $timeout if defined $timeout;
44             $config->{ignore_github_tags} = $ignore_github_tags if defined $ignore_github_tags;
45             $config->{force_git_url} = $force_git_url if defined $force_git_url;
46             $config->{cleanup_cycle} = $cleanup_cycle if defined $cleanup_cycle;
47              
48             pod2usage() unless $config->{work_dir};
49             pod2usage() unless $config->{server_url};
50              
51             my $manager = Ukigumo::Agent::Manager->new(config => $config);
52             Ukigumo::Agent->register_manager($manager);
53              
54             my $static_dir = File::Spec->catdir(Ukigumo::Agent->share_dir, 'static');
55             my $app = builder {
56             enable 'AccessLog';
57              
58             mount '/' => Ukigumo::Agent->to_app;
59             mount '/static/' => Plack::App::File->new({ root => $static_dir })->to_app;
60             };
61              
62             my $twiggy = Twiggy::Server->new(host => $host, port => $port);
63             $twiggy->register_service($app);
64              
65             print "Twiggy: Accepting connections at http://${host}:${port}/\n";
66              
67             AE::cv->recv;
68             __END__