| 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"
MC/DC0%0/1
$ENV{"TOADFARM_STOP_SIGNAL"} //= "QUIT"
$ENV{"TOADFARM_STOP_SIGNAL"}
Truth table50%1/2
A
A= $ENV{"TOADFARM_STOP_SIGNAL"}
| |||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | kill $ENV{TOADFARM_STOP_SIGNAL}, $pid or return $self->_end($!, 'kill failed') if $pid; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%3/4
$pid && (kill($ENV{'TOADFARM_STOP_SIGNAL'}, $pid) || (return $self->_end($!, 'kill failed')))
kill $ENV{"TOADFARM_STOP_SIGNAL"}, $pid or return $self->_end($!, "kill failed")
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
| |||||||||||||||||||||||||||||||
| 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
MC/DC100%1/1
$self->_pid || 0
$self->_pid
Truth table100%2/2
A
A= $self->_pid
| |||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | return $self->_end($self->_is_running ? 1 : 0, $pid ? "running with pid=$pid" : ""); | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||