-
-
Save anonymous/a0aa57435a464b61f011 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Minion/Command/minion/worker.pm b/lib/Minion/Command/minion/worker.pm | |
index a421d38..6b612fa 100644 | |
--- a/lib/Minion/Command/minion/worker.pm | |
+++ b/lib/Minion/Command/minion/worker.pm | |
@@ -1,16 +1,23 @@ | |
package Minion::Command::minion::worker; | |
use Mojo::Base 'Mojolicious::Command'; | |
+use Getopt::Long qw(GetOptionsFromArray :config no_auto_abbrev no_ignore_case); | |
+ | |
has description => 'Start Minion worker.'; | |
has usage => sub { shift->extract_usage }; | |
sub run { | |
- my $self = shift; | |
+ my ($self, @args) = @_; | |
- local $SIG{INT} = local $SIG{TERM} = sub { $self->{finished}++ }; | |
+ GetOptionsFromArray \@args, 't|task=s' => \my @tasks; | |
+ # Limit tasks | |
my $app = $self->app; | |
my $minion = $app->minion; | |
+ $minion->tasks({map { $_ => $minion->tasks->{$_} } @tasks}) if @tasks; | |
+ | |
+ local $SIG{INT} = local $SIG{TERM} = sub { $self->{finished}++ }; | |
+ | |
my $worker = $minion->worker->register; | |
while (!$self->{finished}) { | |
@@ -39,7 +46,13 @@ Minion::Command::minion::worker - Minion worker command | |
Usage: APPLICATION minion worker | |
+ ./myapp.pl minion worker | |
./myapp.pl minion worker -m production | |
+ ./myapp.pl minion worker -t foo -t bar | |
+ | |
+ Options: | |
+ -t, --task <name> One or more tasks to handle, defaults to handling all | |
+ tasks. | |
=head1 DESCRIPTION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment