2015-03-27 09:04:25 +00:00
|
|
|
#
|
|
|
|
# spec file for package perl-Minion
|
|
|
|
#
|
2017-01-03 08:22:09 +00:00
|
|
|
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
2015-03-27 09:04:25 +00:00
|
|
|
#
|
|
|
|
# All modifications and additions to the file contributed by third parties
|
|
|
|
# remain the property of their copyright owners, unless otherwise agreed
|
|
|
|
# upon. The license for this file, and modifications and additions to the
|
|
|
|
# file, is the same license as for the pristine package itself (unless the
|
|
|
|
# license for the pristine package is not an Open Source License, in which
|
|
|
|
# case the license is the MIT License). An "Open Source License" is a
|
|
|
|
# license that conforms to the Open Source Definition (Version 1.9)
|
|
|
|
# published by the Open Source Initiative.
|
|
|
|
|
|
|
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
Name: perl-Minion
|
2017-01-03 08:22:09 +00:00
|
|
|
Version: 6.02
|
2015-03-27 09:04:25 +00:00
|
|
|
Release: 0
|
|
|
|
%define cpan_name Minion
|
|
|
|
Summary: Job queue
|
|
|
|
License: Artistic-2.0
|
|
|
|
Group: Development/Libraries/Perl
|
|
|
|
Url: http://search.cpan.org/dist/Minion/
|
2015-04-22 13:58:51 +00:00
|
|
|
Source0: http://www.cpan.org/authors/id/S/SR/SRI/%{cpan_name}-%{version}.tar.gz
|
|
|
|
Source1: cpanspec.yml
|
2015-03-27 09:04:25 +00:00
|
|
|
BuildArch: noarch
|
|
|
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
|
|
|
BuildRequires: perl
|
|
|
|
BuildRequires: perl-macros
|
|
|
|
BuildRequires: perl(Mojolicious) >= 6.0
|
|
|
|
Requires: perl(Mojolicious) >= 6.0
|
|
|
|
%{perl_requires}
|
|
|
|
|
|
|
|
%description
|
2016-01-14 06:39:59 +00:00
|
|
|
Minion is a job queue for the at http://mojolicious.org real-time web
|
2016-02-20 20:44:19 +00:00
|
|
|
framework, with support for multiple named queues, priorities, delayed
|
2016-05-25 07:45:51 +00:00
|
|
|
jobs, job dependencies, job results, retries with backoff, statistics,
|
2016-09-23 04:16:06 +00:00
|
|
|
distributed workers, parallel processing, autoscaling, remote control,
|
|
|
|
resource leak protection and multiple backends (such as at
|
|
|
|
http://www.postgresql.org).
|
2015-03-27 09:04:25 +00:00
|
|
|
|
2016-02-20 20:44:19 +00:00
|
|
|
Job queues allow you to process time and/or computationally intensive tasks
|
|
|
|
in background processes, outside of the request/response lifecycle. Among
|
|
|
|
those tasks you'll commonly find image resizing, spam filtering, HTTP
|
2015-03-27 09:04:25 +00:00
|
|
|
downloads, building tarballs, warming caches and basically everything else
|
|
|
|
you can imagine that's not super fast.
|
|
|
|
|
|
|
|
use Mojolicious::Lite;
|
|
|
|
|
|
|
|
plugin Minion => {Pg => 'postgresql://sri:s3cret@localhost/test'};
|
|
|
|
|
|
|
|
# Slow task
|
|
|
|
app->minion->add_task(poke_mojo => sub {
|
|
|
|
my $job = shift;
|
2016-01-14 06:39:59 +00:00
|
|
|
$job->app->ua->get('mojolicious.org');
|
|
|
|
$job->app->log->debug('We have poked mojolicious.org for a visitor');
|
2015-03-27 09:04:25 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
# Perform job in a background worker process
|
|
|
|
get '/' => sub {
|
|
|
|
my $c = shift;
|
|
|
|
$c->minion->enqueue('poke_mojo');
|
2016-01-14 06:39:59 +00:00
|
|
|
$c->render(text => 'We will poke mojolicious.org for you soon.');
|
2015-03-27 09:04:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
app->start;
|
|
|
|
|
2015-11-11 14:56:10 +00:00
|
|
|
Background worker processes are usually started with the command
|
|
|
|
Minion::Command::minion::worker, which becomes automatically available when
|
|
|
|
an application loads the plugin Mojolicious::Plugin::Minion.
|
2015-03-27 09:04:25 +00:00
|
|
|
|
|
|
|
$ ./myapp.pl minion worker
|
|
|
|
|
2015-11-11 14:56:10 +00:00
|
|
|
Jobs can be managed right from the command line with
|
|
|
|
Minion::Command::minion::job.
|
2015-03-27 09:04:25 +00:00
|
|
|
|
|
|
|
$ ./myapp.pl minion job
|
|
|
|
|
2016-09-02 06:08:49 +00:00
|
|
|
To manage background worker processes with systemd, you can use a unit
|
|
|
|
configuration file like this.
|
|
|
|
|
|
|
|
[Unit]
|
|
|
|
Description=My Mojolicious application workers
|
|
|
|
After=postgresql.service
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=simple
|
|
|
|
ExecStart=/home/sri/myapp/myapp.pl minion worker -m production
|
|
|
|
KillMode=process
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
2015-03-27 09:04:25 +00:00
|
|
|
Every job can fail or succeed, but not get lost, the system is eventually
|
|
|
|
consistent and will preserve job results for as long as you like, depending
|
2016-01-14 06:39:59 +00:00
|
|
|
on "remove_after". While individual workers can fail in the middle of
|
2015-11-11 14:56:10 +00:00
|
|
|
processing a job, the system will detect this and ensure that no job is
|
2016-01-14 06:39:59 +00:00
|
|
|
left in an uncertain state, depending on "missing_after".
|
2015-03-27 09:04:25 +00:00
|
|
|
|
|
|
|
%prep
|
|
|
|
%setup -q -n %{cpan_name}-%{version}
|
|
|
|
|
|
|
|
%build
|
|
|
|
%{__perl} Makefile.PL INSTALLDIRS=vendor
|
|
|
|
%{__make} %{?_smp_mflags}
|
|
|
|
|
|
|
|
%check
|
|
|
|
%{__make} test
|
|
|
|
|
|
|
|
%install
|
|
|
|
%perl_make_install
|
|
|
|
%perl_process_packlist
|
|
|
|
%perl_gen_filelist
|
|
|
|
|
|
|
|
%files -f %{name}.files
|
|
|
|
%defattr(-,root,root,755)
|
2016-05-25 07:45:51 +00:00
|
|
|
%doc Changes examples LICENSE README.md
|
2015-03-27 09:04:25 +00:00
|
|
|
|
|
|
|
%changelog
|