TaskPipe/Tool/Command_StopJob.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 94.1% 32 / 34 CC 2 SCAR 2.3
CC
2
Cov
96%
execute
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« TaskPipe/Task_SourceFromFile.pm ↑ Summary TaskPipe/Plan.pm »
1 package TaskPipe::Tool::Command_StopJob;
2  
3 32 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 32 ▶use TaskPipe::JobManager;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 32 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 32 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 32 extends 'TaskPipe::Tool::Command';
8  
9  
10 has option_specs => (is => 'ro', isa => 'ArrayRef', default => sub{[{
11 560 ▶ module => __PACKAGE__,
Subroutine __ANON__: called CC=1 SCAR=0.0
12 is_config => 0
13 32 }]});
14  
15 has job_manager => (is => 'ro', isa => 'TaskPipe::JobManager', lazy => 1, default => sub{
16 140 ▶ TaskPipe::JobManager->new(
Subroutine __ANON__: called CC=1 SCAR=0.0
17 name => $_[0]->name,
18 project => '*global',
19 shell => 'foreground'
20 );
21 32 });
22  
23  
24  
25 sub execute{
26 140 ▶ my $self = shift;
Subroutine execute: called CC=2 SCAR=7.0
Pod undocumented
27  
28 140 $self->run_info->scope( 'global' );
29 140 ▶ confess "job_id must be provided" unless $self->job_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->job_id 0 140 140
30 140 $self->job_manager->stop_job( $self->job_id );
31  
32 }
33  
34 =head1 NAME
35  
36 TaskPipe::Tool::Command_StopJob - command to stop a running taskpipe job
37  
38 =head1 PURPOSE
39  
40 Stop a TaskPipe process. Usually you want to do this because you started a job in the background (using the C<--shell=background> parameter).
41  
42 =head1 DESCRIPTION
43  
44 For example if earlier you executed the command
45  
46 taskpipe run plan --shell=background
47  
48 and you wanted to stop that job then you should first run
49  
50 taskpipe show jobs
51  
52 use the list which is returned to identify the job id corresponding to the C<run plan> command, then type
53  
54 taskpipe stop job --job_id=<insert job id>
55  
56 Using C<stop job> rather than manually killing processes is recommended where possible, because jobs can involve multiple threads and subprocesses (such as TOR instances) which C<stop job> will attempt to identify and shut down appropriately.
57  
58  
59 =head1 OPTIONS
60  
61 =over
62  
63 =item job_id
64  
65 The ID of the job you want to stop. To find the C<job_id>, use C<show jobs>.
66  
67 =back
68  
69 =cut
70  
71 32 has job_id => (is => 'ro', isa => 'Str');
72  
73 =head1 AUTHOR
74  
75 Tom Gracey <tomgracey@gmail.com>
76  
77 =head1 COPYRIGHT AND LICENSE
78  
79 Copyright (c) Tom Gracey 2018
80  
81 TaskPipe is free software, licensed under
82  
83 The GNU Public License Version 3
84  
85 =cut
86  
87  
88 32 __PACKAGE__->meta->make_immutable;
89 32 1;
« TaskPipe/Task_SourceFromFile.pm ↑ Summary TaskPipe/Plan.pm »