Toadfarm/Command/stop.pm

filter: Statementstmt 100% 19 / 19 Branchbran 100% 8 / 8 Conditioncond 75.0% 6 / 8 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 88.8% 40 / 45 CC 7 SCAR 15.7
CC
7
Cov
94%
_stop
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.8
« Toadfarm/Command/tail.pm ↑ Summary Toadfarm/Command/start.pm »
1 package Toadfarm::Command::stop;
2 2 ▶use Mojo::Base 'Toadfarm::Command::start';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Time::HiRes 'usleep';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶$ENV{TOADFARM_STOP_SIGNAL} //= 'QUIT';
Condition50%1/2
$ENV{"TOADFARM_STOP_SIGNAL"} //= "QUIT"
l!l
02
MC/DC0%0/1
$ENV{"TOADFARM_STOP_SIGNAL"} //= "QUIT"
$ENV{"TOADFARM_STOP_SIGNAL"}
Truth table50%1/2
A
A= $ENV{"TOADFARM_STOP_SIGNAL"}
Aresult
11
00
6  
7 2 has description => 'Toadfarm: Stop the server';
8  
9 3 ▶sub run { shift->_stop(@_) }
Subroutine run: called CC=1 SCAR=0.0
Pod documented
10  
11 6 ▶sub _stop {
Subroutine _stop: called CC=7 SCAR=19.5
12 6 my $self = shift;
13 6 my $pid = $self->_pid;
14  
15 # stop
16 6 $self->_log_daemon_msg('Stopping the process %s');
17 6 ▶ return $self->_end(0) unless $self->_is_running;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_running 3 3 6
18 3 ▶ kill $ENV{TOADFARM_STOP_SIGNAL}, $pid or return $self->_end($!, 'kill failed') if $pid;
Branch: 1 branch
BranchTrueFalseTotal
if $pid 2 1 3
Condition75%3/4
$pid && (kill($ENV{'TOADFARM_STOP_SIGNAL'}, $pid) || (return $self->_end($!, 'kill failed')))
!ll
12
kill $ENV{"TOADFARM_STOP_SIGNAL"}, $pid or return $self->_end($!, "kill failed")
l!l
20
MC/DC0%0/2
$pid && (kill($ENV{'TOADFARM_STOP_SIGNAL'}, $pid) || (return $self->_end($!, 'kill failed')))
$pid kill $ENV{"TOADFARM_STOP_SIGNAL"}, $pid
Truth table33%1/3
A && B
A= $pidB= kill $ENV{"TOADFARM_STOP_SIGNAL"}, $pid
ABresult
0X0
100
111
19  
20 # wait until stopped
21 3 ▶ $self->_wait_for(sub { !shift->_is_running });
Subroutine __ANON__: called CC=1 SCAR=0.0
22  
23 # check if stopped
24 3 ▶ $pid = $self->_pid || 0;
Condition100%2/2
$self->_pid || 0
l!l
12
MC/DC100%1/1
$self->_pid || 0
$self->_pid
Truth table100%2/2
A
A= $self->_pid
Aresult
11
00
25 3 ▶ return $self->_end($self->_is_running ? 1 : 0, $pid ? "running with pid=$pid" : "");
Branch: 2 branches
BranchTrueFalseTotal
$self->_is_running ? : 2 1 3
$pid ? : 1 2 3
26 }
27  
28 2 1;
29  
30 =encoding utf8
31  
32 =head1 NAME
33  
34 Toadfarm::Command::stop - Stop a Toadfarm DSL script
35  
36 =head1 DESCRIPTION
37  
38 L<Toadfarm::Command::stop> is a command for stopping a L<Toadfarm> application.
39  
40 =head1 SYNOPSIS
41  
42 $ /path/to/script.pl stop
43  
44 =head1 ATTRIBUTES
45  
46 =head2 description
47  
48 Short description of command, used for the command list.
49  
50 =head1 METHODS
51  
52 =head2 run
53  
54 Run command.
55  
56 =head1 COPYRIGHT AND LICENSE
57  
58 Copyright (C) 2014, Jan Henning Thorsen
59  
60 This program is free software, you can redistribute it and/or modify it under
61 the terms of the Artistic License version 2.0.
62  
63 =head1 AUTHOR
64  
65 Jan Henning Thorsen - C<jhthorsen@cpan.org>
66  
67 =cut
« Toadfarm/Command/tail.pm ↑ Summary Toadfarm/Command/start.pm »