| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Beam::Minion::Command::run; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.016'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Command to enqueue a job on Beam::Minion job queue |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
#pod |
|
7
|
|
|
|
|
|
|
#pod beam minion run [-d ] [-a ] [-p
|
|
8
|
|
|
|
|
|
|
#pod [...] |
|
9
|
|
|
|
|
|
|
#pod |
|
10
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
11
|
|
|
|
|
|
|
#pod |
|
12
|
|
|
|
|
|
|
#pod This command adds a job to the L queue to execute the given |
|
13
|
|
|
|
|
|
|
#pod C from the given C. |
|
14
|
|
|
|
|
|
|
#pod |
|
15
|
|
|
|
|
|
|
#pod In order for the job to run, you must run a Minion worker using the |
|
16
|
|
|
|
|
|
|
#pod L. |
|
17
|
|
|
|
|
|
|
#pod |
|
18
|
|
|
|
|
|
|
#pod =head1 ARGUMENTS |
|
19
|
|
|
|
|
|
|
#pod |
|
20
|
|
|
|
|
|
|
#pod =head2 container |
|
21
|
|
|
|
|
|
|
#pod |
|
22
|
|
|
|
|
|
|
#pod The container that contains the task to run. This can be an absolute |
|
23
|
|
|
|
|
|
|
#pod path to a container file, a relative path from the current directory, or |
|
24
|
|
|
|
|
|
|
#pod a relative path from one of the directories in the C environment |
|
25
|
|
|
|
|
|
|
#pod variable (separated by C<:>). |
|
26
|
|
|
|
|
|
|
#pod |
|
27
|
|
|
|
|
|
|
#pod =head2 service |
|
28
|
|
|
|
|
|
|
#pod |
|
29
|
|
|
|
|
|
|
#pod The service that defines the task to run. Must be an object that consumes |
|
30
|
|
|
|
|
|
|
#pod the L role. |
|
31
|
|
|
|
|
|
|
#pod |
|
32
|
|
|
|
|
|
|
#pod =head1 OPTIONS |
|
33
|
|
|
|
|
|
|
#pod |
|
34
|
|
|
|
|
|
|
#pod =head2 delay |
|
35
|
|
|
|
|
|
|
#pod |
|
36
|
|
|
|
|
|
|
#pod The amount of time, in seconds, to delay the start of the job (from now). |
|
37
|
|
|
|
|
|
|
#pod Defaults to C<0>. |
|
38
|
|
|
|
|
|
|
#pod |
|
39
|
|
|
|
|
|
|
#pod =head2 attempts |
|
40
|
|
|
|
|
|
|
#pod |
|
41
|
|
|
|
|
|
|
#pod The number of times to automatically retry the job if it fails. |
|
42
|
|
|
|
|
|
|
#pod Subsequent attempts will be delayed by an increasing amount of time |
|
43
|
|
|
|
|
|
|
#pod (calculated by C<(retries ** 4) + 15>). |
|
44
|
|
|
|
|
|
|
#pod |
|
45
|
|
|
|
|
|
|
#pod =head2 priority |
|
46
|
|
|
|
|
|
|
#pod |
|
47
|
|
|
|
|
|
|
#pod The job's priority. Higher priority jobs will be run first. Defaults to C<0>. |
|
48
|
|
|
|
|
|
|
#pod |
|
49
|
|
|
|
|
|
|
#pod =head1 ENVIRONMENT |
|
50
|
|
|
|
|
|
|
#pod |
|
51
|
|
|
|
|
|
|
#pod =head2 BEAM_MINION |
|
52
|
|
|
|
|
|
|
#pod |
|
53
|
|
|
|
|
|
|
#pod This variable defines the shared database to coordinate the Minion workers. This |
|
54
|
|
|
|
|
|
|
#pod database is used to queue the job. This must be the same for all workers |
|
55
|
|
|
|
|
|
|
#pod and every job running. |
|
56
|
|
|
|
|
|
|
#pod |
|
57
|
|
|
|
|
|
|
#pod See L for how to set this variable. |
|
58
|
|
|
|
|
|
|
#pod |
|
59
|
|
|
|
|
|
|
#pod =head2 BEAM_PATH |
|
60
|
|
|
|
|
|
|
#pod |
|
61
|
|
|
|
|
|
|
#pod This variable is a colon-separated list of directories to search for |
|
62
|
|
|
|
|
|
|
#pod containers. |
|
63
|
|
|
|
|
|
|
#pod |
|
64
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
|
65
|
|
|
|
|
|
|
#pod |
|
66
|
|
|
|
|
|
|
#pod L, L |
|
67
|
|
|
|
|
|
|
#pod |
|
68
|
|
|
|
|
|
|
#pod =cut |
|
69
|
|
|
|
|
|
|
|
|
70
|
1
|
|
|
1
|
|
70093
|
use Mojo::Base -base; |
|
|
1
|
|
|
|
|
186692
|
|
|
|
1
|
|
|
|
|
8
|
|
|
71
|
1
|
|
|
1
|
|
661
|
use Beam::Minion; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
43
|
|
|
72
|
1
|
|
|
1
|
|
13
|
use Getopt::Long qw( GetOptionsFromArray ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub run { |
|
75
|
3
|
|
|
3
|
0
|
80219
|
my ( $self, $container, $service_name, @args ) = @_; |
|
76
|
3
|
|
|
|
|
32
|
GetOptionsFromArray( \@args, \my %opt, |
|
77
|
|
|
|
|
|
|
'delay|d=i', |
|
78
|
|
|
|
|
|
|
'attempts|a=i', |
|
79
|
|
|
|
|
|
|
'priority|p=i', |
|
80
|
|
|
|
|
|
|
); |
|
81
|
3
|
|
|
|
|
1669
|
Beam::Minion->enqueue( $container, $service_name, \@args, \%opt ); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |