Skip to content

Instantly share code, notes, and snippets.

@brianmed
Created October 25, 2016 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianmed/770ae233a258d8dd5d23317ec6c4bdf0 to your computer and use it in GitHub Desktop.
Save brianmed/770ae233a258d8dd5d23317ec6c4bdf0 to your computer and use it in GitHub Desktop.
Very small minion retry example
use Mojolicious::Lite;
app->log->level("debug");
plugin Minion => { SQLite => 'sqlite:minimal_minion.db' };
app->minion->add_task(generate_image => sub {
my ($job, @args) = @_;
srand();
my $rand = int(rand(10));
app->log->info("$job rand: $rand");
if (5 < $rand) {
app->log->info("$job retrying");
$job->finish;
$job->retry({ delay => 5 });
return;
}
app->log->info("$job done");
$job->finish;
});
app->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment