Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/Minion/Command/minion/worker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,21 @@ sub run {

my $log = $self->app->log;
$log->info("Worker $$ started");
$worker->on(dequeue => sub { pop->once(spawn => \&_spawn) });
$worker->on(dequeue => sub {
$_[1]->once(failed => \&_failed);
$_[1]->once(spawn => \&_spawn);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use $_[1] over multiple lines.

});
$worker->run;
$log->info("Worker $$ stopped");
}

sub _failed {
my($job, $error) = @_;
my($id, $task) = ($job->id, $job->task);
$error =~ s/\n//;
$job->app->log->debug(qq{Job "$id", task "$task" failed: $error});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message format is rather inconsistent.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to provide positive feedback on what a a consistent message should look like instead....

}

sub _spawn {
my ($job, $pid) = @_;
my ($id, $task) = ($job->id, $job->task);
Expand Down