=encoding utf8
=head1 Mojolicious::Plugin::Minion::Workers
★★★ Доброго всем ★★★
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
=head1 VERSION
0.9095 (up to Minion version/10+C)
=head1 NAME
Mojolicious::Plugin::Minion::Workers - does extend base Mojolicious::Plugin::Minion
on manage Minion workers.
=head1 SYNOPSIS
# Mojolicious (define amount workers in config)
$self->plugin('Minion::Workers' => {Pg => ..., workers=>2, manage=>1, });
# or pass to $app->minion->workers->manage() for run later
$self->plugin('Minion::Workers' => {Pg => ...});
# Mojolicious::Lite (define amount workers in config)
plugin 'Minion::Workers' => {Pg => ..., workers=>2};
# Add tasks to your application
app->minion->add_task(something_slow => sub {
my ($job, @args) = @_;
...
});
# But you can define tasks in config as well
$self->plugin('Minion::Workers' => {Pg => ..., tasks => { foo_task => sub { ... }, }, });
# Start manage with amount workers
app->minion->workers->manage(4);
# or get number from config
app->minion->workers->manage();
# Start jobs from anywhere in your application
=head1 DESCRIPTION
L is a L plugin for the L job
queue and has extending base L for enable workers managment.
=head1 Extend base plugin config
L apply all config options
of the base plugin L, and define following:
=head2 workers =>
Amount of Minion workers need to start/restart. None defaults.
This value can be overriden on C<< $app->minion->workers->manage(...) >>.
..., workers => 4, ...
=head2 manage =>
Start/restart Minion workers during plugin registration. Defaults to false.
If this option is not set then you can start Minion workers
by C<< $app->minion->workers->manage() >> see below.
..., manage => 1, ...
=head2 tasks =>
You can define Minion tasks in config.
..., tasks => {foo_task => sub { ... }, ...},
=head2 => | |
If config parameter B is a B then returned value (connection string or backend object)
from callback will reassigned to B config option,
i.e. C<< $conf->{} = $conf->{}->($app); >>.
..., Pg => sub { my $app = shift; ... }, ...
=head1 Manage workers
L add attr B to the C<< $app->minion >> object.
The C<< $app->minion->workers >> object has following public methods.
=head2 manage(integer amount)
Start/restart Minion passed amount workers or get its from plugin config.
None workers mean skip managment.
$app->minion->workers->manage(2);
Tested manual on standard shell commands (on Linux) with L:
$ perl script/app.pl daemon # one Minion worker will be starting
$ perl script/app.pl prefork # your amount Minion workers will be starting
$ morbo script/app.pl # when morbo restarts on watch changes one Minion worker will be restarting too
$ hypnotoad script/app.pl # your amount Minion workers will be starting
$ hypnotoad script/app.pl # on hot deploy Minion workers will be restarting too
$ hypnotoad -s script/app.pl # Minion workers will stoping too
B. For shell commands C< $ morbo script/app.pl > and C< $ perl script/app.pl daemon >
amount Minion workers is B process always.
B. In case with hypnotoad if you want C< $ kill -USR2 app_pid >
then Minion workers will not restarts, sorry.
Always use hot deploy command C< $ hypnotoad script/app.pl >.
B. When Minion workers restarts (hypnotoad | morbo) then
B exists Minion processes stopped and then running.
So if you run many separate apps with one database backend
then dont use this module or set separate backend databases as well.
B. PSGI application did not tested.
B. With L Minion workers starting but jobs does not execute.
An other backends even not tested.
=head1 HELPERS
L enable all helpers through
base plugin L,
thus you dont need apply base plugin (auto register).
=head1 METHODS
L inherits all methods from
L and override the following new ones.
=head2 register
$plugin->register(Mojolicious->new, );
Register plugin in L application.
=head1 SEE ALSO
L, L, L, L.
=head1 AUTHOR
Михаил Че (Mikhail Che), C<< >>
=head1 BUGS / CONTRIBUTING
Please report any bugs or feature requests at
L.
Pull requests also welcome.
=head1 COPYRIGHT
Copyright 2019+ Mikhail Che.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
The Tidelift Subscription provides access to a continuously curated stream of human-researched and maintainer-verified data on open source packages and their licenses, releases, vulnerabilities, and development practices.