Last active
November 22, 2018 19:36
-
-
Save preaction/bdce415e3098d827eaed3f01b545d9f0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Time::HiRes qw( time ); | |
plugin Minion => { | |
SQLite => 'sqlite:' . app->home->child('minion.db'), | |
}; | |
app->minion->add_task( | |
ping => sub { | |
my ( $job, $url ) = @_; | |
my $start = time; | |
my $tx = $job->app->ua->head( $url ); | |
my $elapsed = time - $start; | |
$job->app->log->info( | |
sprintf 'Fetching %s took %.3f seconds', $url, $elapsed | |
); | |
$job->finish( $elapsed ); | |
} | |
); | |
app->start; |
This file contains hidden or 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
perl minion.pl worker |
This file contains hidden or 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
perl minion.pl job -e ping -a '["http://mojolicious.org"]' | |
perl minion.pl job -e ping -a '["http://mojolicious.io"]' | |
perl minion.pl job -e ping -a '["http://google.com"]' | |
perl minion.pl job -e ping -a '["http://example.com"]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment