Author image Михаил Че
and 1 contributors

Mojolicious::Plugin::Minion::Workers

Доброго всем

¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !

VERSION

0.09072 (up to Minion 9.07)

NAME

Mojolicious::Plugin::Minion::Workers - does extend base Mojolicious::Plugin::Minion on manage Minion workers.

SYNOPSIS

  # Mojolicious (define amount workers in config)
  $self->plugin('Minion::Workers' => {Pg => ..., workers=>2});
  # or pass to $app->minion->manage_workers(<num>) 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(slow_log => sub {
    my ($job, $msg) = @_;
    sleep 5;
    $job->app->log->debug(qq{Received message "$msg"});
  });
  
  # Allow manage with amount workers (gets from config)
  app->minion->manage_workers();
  # or override config workers by pass
  app->minion->manage_workers(4);

  # Start jobs from anywhere in your application

DESCRIPTION

Mojolicious::Plugin::Minion::Workers is a Mojolicious plugin for the Minion job queue and has extending base Mojolicious::Plugin::Minion for enable workers managment.

Manage workers

Mojolicious::Plugin::Minion::Workers has patch the Minion module on the following new one method.

manage_workers(int)

Start/restart Minion passed amount workers or get its from plugin config. None workers mean skip managment.

  $app->minion->manage_workers(1);

Tested on standard commands:

  $ perl script/app.pl daemon
  $ perl script/app.pl prefork
  $ morbo script/app.pl # yes,  worker will restarted when morbo restarts on watch changes
  $ hypnotoad script/app.pl
  $ hypnotoad script/app.pl # hot deploy (TODO: graceful restarting minion workers)
  $ hypnotoad -s script/app.pl # yes, minion workers will stoped too

NOTE for commands $ morbo script/app.pl and $ perl script/app.pl daemon workers always one.

HELPERS

Mojolicious::Plugin::Minion::Workers enable all helpers from base plugin Mojolicious::Plugin::Minion, thus you dont need apply base plugin (auto register).

METHODS

Mojolicious::Plugin::Minion::Workers inherits all methods from Mojolicious::Plugin::Minion and override the following new ones.

register

  $plugin->register(Mojolicious->new, {Pg => ..., worker=>1});

Register plugin in Mojolicious application.

SEE ALSO

Mojolicious::Plugin::Minion, Minion, Mojolicious::Guides, https://mojolicious.org.

AUTHOR

Михаил Че (Mikhail Che), <mche[-at-]cpan.org>

BUGS / CONTRIBUTING

Please report any bugs or feature requests at https://github.com/mche/Mojolicious-Plugin-Minion-Workers/issues. Pull requests also welcome.

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.