| 1 | package TaskPipe::Tool::Command_ShowJobs; | ||
| 2 | |||
| 3 | use Moose; | ||
| 4 | use TaskPipe::JobManager; | ||
| 5 | use Carp; | ||
| 6 | use Text::Table::TinyColor 'generate_table'; | ||
| 7 | use Term::ANSIColor; | ||
| 8 | extends 'TaskPipe::Tool::Command'; | ||
| 9 | |||
| 10 | |||
| 11 | has job_manager => (is => 'ro', isa => 'TaskPipe::JobManager', lazy => 1, default => sub{ | ||
| 12 | TaskPipe::JobManager->new( | ||
| 13 | name => $_[0]->name, | ||
| 14 | project => '*global', | ||
| 15 | shell => 'foreground' | ||
| 16 | ); | ||
| 17 | }); | ||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | sub execute{ | ||
| 22 | my $self = shift; | ||
| 23 | |||
| 24 | $self->run_info->scope( 'global' ); | ||
| 25 | |||
| 26 | my @cols = qw(id name project pid shell orig_cmd created_dt); | ||
| 27 | |||
| 28 | my $list = $self->job_manager->list_jobs( @cols ); | ||
| 29 | |||
| 30 | for my $i (0..$#cols){ | ||
| 31 | $cols[$i] = colored( $cols[$i], 'bright_blue' ); | ||
| 32 | } | ||
| 33 | |||
| 34 | my $rows = [ \@cols, @$list ]; | ||
| 35 | print generate_table(rows => $rows, header_row => 1)."\n"; | ||
| 36 | |||
| 37 | } | ||
| 38 | |||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | =head1 NAME | ||
| 43 | |||
| 44 | TaskPipe::Tool::Command_ShowJobs - show currently running TaskPipe jobs | ||
| 45 | |||
| 46 | =head1 PURPOSE | ||
| 47 | |||
| 48 | Show a list of the currently executing TaskPipe jobs on the system | ||
| 49 | |||
| 50 | =head1 DESCRIPTION | ||
| 51 | |||
| 52 | C<show jobs> is useful when you have processes running in the background (i.e. you executed them using the C<--shell=background> parameter.) | ||
| 53 | |||
| 54 | To stop a TaskPipe process which is running in the background, you can use C<show jobs> to find the TaskPipe C<job_id> and use this in combination with C<stop job> | ||
| 55 | |||
| 56 | taskpipe show jobs | ||
| 57 | taskpipe stop job --job_id=<insert job id> | ||
| 58 | |||
| 59 | See the help for C<stop job> for more information. | ||
| 60 | |||
| 61 | =head1 AUTHOR | ||
| 62 | |||
| 63 | Tom Gracey <tomgracey@gmail.com> | ||
| 64 | |||
| 65 | =head1 COPYRIGHT AND LICENSE | ||
| 66 | |||
| 67 | Copyright (c) Tom Gracey 2018 | ||
| 68 | |||
| 69 | TaskPipe is free software, licensed under | ||
| 70 | |||
| 71 | The GNU Public License Version 3 | ||
| 72 | |||
| 73 | =cut | ||
| 74 |