| 1 | package TaskPipe::Tool::Command_StopJob; | ||||||||||
| 2 | |||||||||||
| 3 | 30 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 30 | ▶ | use TaskPipe::JobManager; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 30 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 30 | ▶ | use DateTime; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 30 | extends 'TaskPipe::Tool::Command'; | |||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | has option_specs => (is => 'ro', isa => 'ArrayRef', default => sub{[{ | ||||||||||
| 11 | 472 | ▶ | module => __PACKAGE__, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 12 | is_config => 0 | ||||||||||
| 13 | 30 | }]}); | |||||||||
| 14 | |||||||||||
| 15 | has job_manager => (is => 'ro', isa => 'TaskPipe::JobManager', lazy => 1, default => sub{ | ||||||||||
| 16 | 118 | ▶ | TaskPipe::JobManager->new( | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 17 | name => $_[0]->name, | ||||||||||
| 18 | project => '*global', | ||||||||||
| 19 | shell => 'foreground' | ||||||||||
| 20 | ); | ||||||||||
| 21 | 30 | }); | |||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | sub execute{ | ||||||||||
| 26 | 118 | ▶ | my $self = shift; | ||||||||
|
Subroutine
execute: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 27 | |||||||||||
| 28 | 118 | $self->run_info->scope( 'global' ); | |||||||||
| 29 | 118 | ▶ | confess "job_id must be provided" unless $self->job_id; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 118 | $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 | 30 | 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 | 30 | __PACKAGE__->meta->make_immutable; | |||||||||
| 89 | 30 | 1; | |||||||||