| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Kevin::Command::kevin::jobs; |
|
3
|
|
|
|
|
|
|
$Kevin::Command::kevin::jobs::VERSION = '0.5.2'; # TRIAL |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Command to list Minion jobs |
|
5
|
1
|
|
|
1
|
|
29317
|
use Mojo::Base 'Mojolicious::Command'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
522
|
use Kevin::Commands::Util (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
20
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Mojo::Util qw(getopt); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
53
|
|
|
9
|
1
|
|
|
1
|
|
419
|
use Text::Yeti::Table qw(render_table); |
|
|
1
|
|
|
|
|
1016
|
|
|
|
1
|
|
|
|
|
52
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use Time::HiRes qw(time); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
8
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has description => 'List Minion jobs'; |
|
13
|
|
|
|
|
|
|
has usage => sub { shift->extract_usage }; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub run { |
|
16
|
0
|
|
|
0
|
1
|
|
my ($self, @args) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $app = $self->app; |
|
19
|
0
|
|
|
|
|
|
my $minion = $app->minion; |
|
20
|
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my ($args, $options) = ([], {}); |
|
22
|
|
|
|
|
|
|
getopt \@args, |
|
23
|
|
|
|
|
|
|
'l|limit=i' => \(my $limit = 100), |
|
24
|
|
|
|
|
|
|
'o|offset=i' => \(my $offset = 0), |
|
25
|
|
|
|
|
|
|
'q|queue=s' => \$options->{queue}, |
|
26
|
|
|
|
|
|
|
'S|state=s' => \$options->{state}, |
|
27
|
0
|
|
|
|
|
|
't|task=s' => \$options->{task}; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $results = $minion->backend->list_jobs($offset, $limit, $options); |
|
30
|
0
|
|
|
|
|
|
my $items = $results->{jobs}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $spec = $self->_table_spec; |
|
33
|
0
|
|
|
|
|
|
render_table($items, $spec); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
*_created_since = *Kevin::Commands::Util::_created_since; |
|
37
|
|
|
|
|
|
|
*_job_status = *Kevin::Commands::Util::_job_status; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _table_spec { |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
|
|
my $now = time; |
|
42
|
|
|
|
|
|
|
return [ |
|
43
|
|
|
|
|
|
|
qw(id), |
|
44
|
|
|
|
|
|
|
['priority', undef, 'PRI'], |
|
45
|
|
|
|
|
|
|
qw( task state queue ), |
|
46
|
0
|
|
|
0
|
|
|
['created', sub { _created_since($now - shift) }], |
|
47
|
0
|
|
|
0
|
|
|
['state', sub { _job_status($_[1], $now) }, 'STATUS'], |
|
|
0
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
qw(worker), |
|
49
|
|
|
|
|
|
|
]; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#pod =encoding utf8 |
|
55
|
|
|
|
|
|
|
#pod |
|
56
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
57
|
|
|
|
|
|
|
#pod |
|
58
|
|
|
|
|
|
|
#pod Usage: APPLICATION kevin jobs [OPTIONS] |
|
59
|
|
|
|
|
|
|
#pod |
|
60
|
|
|
|
|
|
|
#pod ./myapp.pl kevin jobs |
|
61
|
|
|
|
|
|
|
#pod ./myapp.pl kevin jobs -l 10 -o 20 |
|
62
|
|
|
|
|
|
|
#pod ./myapp.pl kevin jobs -q important -t foo -S inactive |
|
63
|
|
|
|
|
|
|
#pod |
|
64
|
|
|
|
|
|
|
#pod Options: |
|
65
|
|
|
|
|
|
|
#pod -h, --help Show this summary of available options |
|
66
|
|
|
|
|
|
|
#pod -l, --limit Number of jobs to show when listing |
|
67
|
|
|
|
|
|
|
#pod them, defaults to 100 |
|
68
|
|
|
|
|
|
|
#pod -o, --offset Number of jobs to skip when listing |
|
69
|
|
|
|
|
|
|
#pod them, defaults to 0 |
|
70
|
|
|
|
|
|
|
#pod -q, --queue List only jobs in this queue |
|
71
|
|
|
|
|
|
|
#pod -S, --state List only jobs in this state |
|
72
|
|
|
|
|
|
|
#pod -t, --task List only jobs for this task |
|
73
|
|
|
|
|
|
|
#pod |
|
74
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
75
|
|
|
|
|
|
|
#pod |
|
76
|
|
|
|
|
|
|
#pod L lists jobs at a L queue. |
|
77
|
|
|
|
|
|
|
#pod It produces output as below. |
|
78
|
|
|
|
|
|
|
#pod |
|
79
|
|
|
|
|
|
|
#pod ID PRI TASK STATE QUEUE CREATED STATUS WORKER |
|
80
|
|
|
|
|
|
|
#pod 925851 0 resize finished image-resizer 7 minutes ago Finished 7 minutes ago 27297 |
|
81
|
|
|
|
|
|
|
#pod 925838 1000 search failed item-searcher 13 minutes ago Failed 13 minutes ago 27191 |
|
82
|
|
|
|
|
|
|
#pod 925835 1000 upload finished uploader 13 minutes ago Finished 13 minutes ago 27185 |
|
83
|
|
|
|
|
|
|
#pod 925832 1000 search finished item-searcher 13 minutes ago Finished 13 minutes ago 27188 |
|
84
|
|
|
|
|
|
|
#pod 925831 100 poke failed poker 13 minutes ago Failed 13 minutes ago 26819 |
|
85
|
|
|
|
|
|
|
#pod 925830 100 poke failed poker 31 hours ago Failed 31 hours ago 26847 |
|
86
|
|
|
|
|
|
|
#pod |
|
87
|
|
|
|
|
|
|
#pod =head1 ATTRIBUTES |
|
88
|
|
|
|
|
|
|
#pod |
|
89
|
|
|
|
|
|
|
#pod L inherits all attributes from |
|
90
|
|
|
|
|
|
|
#pod L and implements the following new ones. |
|
91
|
|
|
|
|
|
|
#pod |
|
92
|
|
|
|
|
|
|
#pod =head2 description |
|
93
|
|
|
|
|
|
|
#pod |
|
94
|
|
|
|
|
|
|
#pod my $description = $command->description; |
|
95
|
|
|
|
|
|
|
#pod $command = $command->description('Foo'); |
|
96
|
|
|
|
|
|
|
#pod |
|
97
|
|
|
|
|
|
|
#pod Short description of this command, used for the command list. |
|
98
|
|
|
|
|
|
|
#pod |
|
99
|
|
|
|
|
|
|
#pod =head2 usage |
|
100
|
|
|
|
|
|
|
#pod |
|
101
|
|
|
|
|
|
|
#pod my $usage = $command->usage; |
|
102
|
|
|
|
|
|
|
#pod $command = $command->usage('Foo'); |
|
103
|
|
|
|
|
|
|
#pod |
|
104
|
|
|
|
|
|
|
#pod Usage information for this command, used for the help screen. |
|
105
|
|
|
|
|
|
|
#pod |
|
106
|
|
|
|
|
|
|
#pod =head1 METHODS |
|
107
|
|
|
|
|
|
|
#pod |
|
108
|
|
|
|
|
|
|
#pod L inherits all methods from |
|
109
|
|
|
|
|
|
|
#pod L and implements the following new ones. |
|
110
|
|
|
|
|
|
|
#pod |
|
111
|
|
|
|
|
|
|
#pod =head2 run |
|
112
|
|
|
|
|
|
|
#pod |
|
113
|
|
|
|
|
|
|
#pod $command->run(@ARGV); |
|
114
|
|
|
|
|
|
|
#pod |
|
115
|
|
|
|
|
|
|
#pod Run this command. |
|
116
|
|
|
|
|
|
|
#pod |
|
117
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
|
118
|
|
|
|
|
|
|
#pod |
|
119
|
|
|
|
|
|
|
#pod L, L. |
|
120
|
|
|
|
|
|
|
#pod |
|
121
|
|
|
|
|
|
|
#pod =cut |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |