| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 56 | 9 | ▶ | return unless $command && grep /^$command$/, qw(start status restart stop); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$command and grep /^$command$/, ("start", "status", "restart", "stop")
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")
| |||||||||||||||||||||||||||||
| 57 | 9 | $self->$command; | |||||||||||||||||||||||||||
| 58 | 2 | say $self->status_message; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | ; | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 9 | 1; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | __END__ | ||||||||||||||||||||||||||||