Skip to content

Commit

Permalink
add Admin UI
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 16, 2017
1 parent b8da381 commit 32c397b
Show file tree
Hide file tree
Showing 38 changed files with 3,866 additions and 235 deletions.
11 changes: 10 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@

7.10 2017-10-21
8.0 2017-11-16
- Removed job_info and worker_info methods from Minion::Backend and
Minion::Backend::Pg.
- Changed return value of list_jobs and list_workers methods in
Minion::Backend and Minion::Backend::Pg.
- Added new module Mojolicious::Plugin::Minion::Admin.
- Added ids option to list_jobs and list_workers methods in Minion::Backend
and Minion::Backend::Pg.
- Added uptime field to stats methods in Minion, Minion::Backend and
Minion::Backend::Pg.

7.09 2017-10-20
- Fixed a deadlock problem in Minion::Backend::Pg where jobs could fail if two
Expand Down
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ WriteMakefile(
x_IRC => 'irc://irc.perl.org/#mojo'
},
},
PREREQ_PM => {Mojolicious => '7.29'},
PREREQ_PM => {Mojolicious => '7.56'},
test => {TESTS => 't/*.t t/*/*.t'}
);
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# Minion [![Build Status](https://travis-ci.org/kraih/minion.svg?branch=master)](https://travis-ci.org/kraih/minion)

![Screenshot](https://raw.github.com/kraih/minion/master/examples/admin.png)

A job queue for the [Mojolicious](http://mojolicious.org) real-time web
framework, with support for multiple named queues, priorities, delayed jobs,
job progress, job results, retries with backoff, rate limiting, unique jobs,
Expand Down
Binary file added examples/admin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/minion_bench.pl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ sub dequeue {
say "Requesting job info $INFO times";
$before = time;
my $backend = $minion->backend;
$backend->job_info($_) for 1 .. $INFO;
$backend->list_jobs(0, 1, {ids => [$_]}) for 1 .. $INFO;
$elapsed = time - $before;
$avg = sprintf '%.3f', $INFO / $elapsed;
say "Received job info $INFO times in $elapsed seconds ($avg/s)";
Expand Down
71 changes: 69 additions & 2 deletions lib/Minion.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use Carp 'croak';
use Config;
use Minion::Job;
use Minion::Worker;
use Mojo::Date;
use Mojo::Loader 'load_class';
use Mojo::Server;
use Scalar::Util 'weaken';
Expand All @@ -16,7 +17,7 @@ has missing_after => 1800;
has remove_after => 172800;
has tasks => sub { {} };

our $VERSION = '7.10';
our $VERSION = '8.0';

sub add_task { ($_[0]->tasks->{$_[1]} = $_[2]) and return $_[0] }

Expand Down Expand Up @@ -52,7 +53,8 @@ sub guard {
sub job {
my ($self, $id) = @_;

return undef unless my $job = $self->backend->job_info($id);
return undef
unless my $job = $self->backend->list_jobs(0, 1, {ids => [$id]})->{jobs}[0];
return Minion::Job->new(
args => $job->{args},
id => $job->{id},
Expand Down Expand Up @@ -103,6 +105,14 @@ sub worker {

sub _backoff { (shift()**4) + 15 }

# Used by the job command and admin plugin
sub _datetime {
my $hash = shift;
$hash->{$_} and $hash->{$_} = Mojo::Date->new($hash->{$_})->to_datetime
for qw(created delayed finished notified retried started);
return $hash;
}

sub _delegate {
my ($self, $method) = @_;
$self->backend->$method;
Expand Down Expand Up @@ -197,6 +207,13 @@ L<Minion::Command::minion::job>.
$ ./myapp.pl minion job
You can also add a web administration interface by loading the plugin
L<Mojolicious::Plugin::Minion::Admin>. Just make sure to secure access before
making your application publically accessible.
# Admininstration interface under "/minion"
plugin 'Minion::Admin';
To manage background worker processes with systemd, you can use a unit
configuration file like this.
Expand Down Expand Up @@ -625,6 +642,12 @@ Number of jobs in C<inactive> state.
Number of workers that are currently not processing a job.
=item uptime
uptime => 1000
Uptime in seconds.
=back
=head2 unlock
Expand Down Expand Up @@ -669,6 +692,50 @@ This is the class hierarchy of the L<Minion> distribution.
=back
=head1 BUNDLED FILES
The L<Minion> distribution includes a few files with different licenses that
have been bundled for internal use.
=head2 Minion Artwork
Copyright (C) 2017, Sebastian Riedel.
Licensed under the CC-SA License, Version 4.0
L<http://creativecommons.org/licenses/by-sa/4.0>.
=head2 Bootstrap
Copyright (C) 2011-2016 Twitter, Inc.
Licensed under the MIT License, L<http://creativecommons.org/licenses/MIT>.
=head2 D3.js
Copyright (C) 2010-2016, Michael Bostock.
Licensed under the 3-Clause BSD License,
L<https://opensource.org/licenses/BSD-3-Clause>.
=head2 epoch.js
Copyright (C) 2014 Fastly, Inc.
Licensed under the MIT License, L<http://creativecommons.org/licenses/MIT>.
=head2 Font Awesome
Copyright (C) Dave Gandy.
Licensed under the MIT License, L<http://creativecommons.org/licenses/MIT>, and
the SIL OFL 1.1, L<http://scripts.sil.org/OFL>.
=head2 moment.js
Copyright (C) JS Foundation and other contributors.
Licensed under the MIT License, L<http://creativecommons.org/licenses/MIT>.
=head1 AUTHOR
Sebastian Riedel, C<sri@cpan.org>.
Expand Down
Loading

0 comments on commit 32c397b

Please sign in to comment.