Day 11: Who Watches The Minions
Now that I have a Minion job queue, I need to take care of it properly. Are the workers working (have they seized the means of production)? Are jobs completing successfully? Are there any errors? What are they?
Minion Jobs Command
Minion comes with a job
command that
lists the jobs and their statuses.
$ perl myapp.pl minion job
6 inactive default check_url
5 active default check_url
4 failed default check_url
3 failed default check_url
2 finished default check_url
1 finished default check_url
I can look at an individual job's information by passing in the job's ID.
$ perl minion.pl minion job 1
{
"args" => [
"http://mojolicious.org"
],
"attempts" => 1,
"children" => [],
"created" => "2018-11-23T19:15:47Z",
"delayed" => "2018-11-23T19:15:47Z",
"finished" => "2018-11-23T19:15:48Z",
"id" => 1,
"notes" => {},
"parents" => [],
"priority" => 0,
"queue" => "default",
"result" => "0.0716841220855713",
"retried" => undef,
"retries" => 0,
"started" => "2018-11-23T19:15:47Z",
"state" => "finished",
"task" => "check_url",
"worker" => 1
}
But, it'd be a lot nicer if I didn't have to open a terminal, open an SSH connection, and run a command to look at the status of my Minion.
Minion Admin UI
I said I didn't have a web application, and I don't. But if I want a simple web application to check on the status of the Minion workers and read the results of jobs, Minion comes with an Admin UI plugin.
I can add the Minion::Admin plugin the same way I added the Minion plugin:
use Mojolicious::Lite;
plugin Minion => {
SQLite => 'sqlite:' . app->home->child('minion.db'),
};
plugin 'Minion::Admin', {
# Host Admin UI at /
route => app->routes->any('/'),
};
app->start;
Once I add the plugin, I now have a web application that I can run with
the Mojolicious daemon
command.
$ perl myapp.pl daemon
Server available at http://127.0.0.1:3000
Now I can access the Minion UI:
The main page shows the current status. The links at the top show lists of jobs in the given state, any locks that exist, and the workers.
When looking at a list of jobs, I can click the buttons on top left to
manage the job queue, or click on the caret on the right of each job row
to view the details of that job (the same as the job
command shows).
The Minion Admin UI is a great addition to a great tool! View the entire source of the Minion app
Original artwork by Doug Bell, released under CC-BY-SA 4.0. It includes the Minion logo (CC-BY-SA 4.0)
Doug Bell
Doug (preaction) is a long time Perl user. He is the current maintainer of CPAN Testers and the author of many CPAN modules including the Statocles blog engine that powers this site.