# # spec file for package perl-Minion # # Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # 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 Version: 6.02 Release: 0 %define cpan_name Minion Summary: Job queue License: Artistic-2.0 Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/Minion/ Source0: http://www.cpan.org/authors/id/S/SR/SRI/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml 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 Minion is a job queue for the at http://mojolicious.org real-time web framework, with support for multiple named queues, priorities, delayed jobs, job dependencies, job results, retries with backoff, statistics, distributed workers, parallel processing, autoscaling, remote control, resource leak protection and multiple backends (such as at http://www.postgresql.org). 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 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; $job->app->ua->get('mojolicious.org'); $job->app->log->debug('We have poked mojolicious.org for a visitor'); }); # Perform job in a background worker process get '/' => sub { my $c = shift; $c->minion->enqueue('poke_mojo'); $c->render(text => 'We will poke mojolicious.org for you soon.'); }; app->start; 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. $ ./myapp.pl minion worker Jobs can be managed right from the command line with Minion::Command::minion::job. $ ./myapp.pl minion job 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 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 on "remove_after". While individual workers can fail in the middle of processing a job, the system will detect this and ensure that no job is left in an uncertain state, depending on "missing_after". %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) %doc Changes examples LICENSE README.md %changelog