API/Daemon.pm

filter: Statementstmt 97.7% 43 / 44 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 2 / 2 totaltotal 89.5% 60 / 67 CC 5 SCAR 7.7
CC
5
Cov
91%
run
4.6
__ANON__
2.0
BEGIN
1.0
CRAP 2.2
« API.pm ↑ Summary
1 package Tapper::Reports::API::Daemon;
2 9 our $AUTHORITY = 'cpan:TAPPER';
3 9 $Tapper::Reports::API::Daemon::VERSION = '5.0.5';
4 9 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 9 ▶use Tapper::Reports::API;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 ▶use Tapper::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 ▶use Log::Log4perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 9 with 'MooseX::Daemonize';
15  
16 9 has server => (is => 'rw');
17 9 has port => (is => 'rw', isa => 'Int', default => 7358);
18  
19 7 ▶after start => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
20 7 my $self = shift;
21  
22 7 ▶ return unless $self->is_daemon;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_daemon 1 6 7
23  
24 6 my $logconf = Tapper::Config->subconfig->{files}{log4perl_cfg};
25 6 Log::Log4perl->init($logconf);
26  
27 6 $self->initialize_server;
28 0 $self->server->server_loop;
29 }
30 9 ;
31  
32  
33 sub initialize_server
34 6 ▶{
Subroutine initialize_server: called CC=1 SCAR=0.0
Pod documented
35 6 my $self = shift;
36  
37 6 my $EUID = `id -u`; chomp $EUID;
38 6 my $EGID = `id -g`; chomp $EGID;
39 6 Tapper::Reports::API->run(
40 port => $self->port,
41 log_level => 2,
42 max_servers => 10,
43 max_requests => 10,
44 user => $EUID,
45 group => $EGID,
46 );
47 }
48 ;
49  
50  
51 sub run
52 9 ▶{
Subroutine run: called CC=4 SCAR=15.2
Pod documented
53 9 my $self = shift;
54  
55 9 ▶ my ($command) = @ARGV ? @ARGV : @_;
Branch: 1 branch
BranchTrueFalseTotal
@ARGV ? : 0 9 9
56 9 ▶ return unless $command && grep /^$command$/, qw(start status restart stop);
Branch: 1 branch
BranchTrueFalseTotal
unless $command and grep /^$command$/, ("start", "status", "restart", "stop") 0 9 9
Condition33%1/3
$command and grep /^$command$/, ("start", "status", "restart", "stop")
!ll&&!rl&&r
009
MC/DC0%0/2
$command and grep /^$command$/, ("start", "status", "restart", "stop")
$command grep /^$command$/, ("start", "status", "restart", "stop")
Truth table33%1/3
A and B
A= $commandB= grep /^$command$/, ("start", "status", "restart", "stop")
ABresult
0X0
100
111
57 9 $self->$command;
58 2 say $self->status_message;
59 }
60 ;
61  
62  
63 9 1;
64  
65 __END__
« API.pm ↑ Summary