https://github.com/preaction/beam-minion
A distributed task runner using Beam and Minion
https://github.com/preaction/beam-minion
Last synced: about 1 year ago
JSON representation
A distributed task runner using Beam and Minion
- Host: GitHub
- URL: https://github.com/preaction/beam-minion
- Owner: preaction
- License: other
- Created: 2017-01-04T22:35:37.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-03-08T03:06:11.000Z (over 7 years ago)
- Last Synced: 2024-06-19T02:05:02.927Z (about 2 years ago)
- Language: Perl
- Size: 91.8 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkdn
- Changelog: CHANGES
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# NAME
Beam::Minion - A distributed task runner for Beam::Wire containers
# VERSION
version 0.016
# STATUS
# SYNOPSIS
# Command-line interface
export BEAM_MINION=sqlite://test.db
beam minion worker
beam minion run [...]
beam minion help
# Perl interface
local $ENV{BEAM_MINION} = 'sqlite://test.db';
Beam::Minion->enqueue( $container, $service, \@args, \%opt );
# DESCRIPTION
[Beam::Minion](https://metacpan.org/pod/Beam::Minion) is a distributed task runner. One or more workers are
created to run tasks, and then each task is sent to a worker to be run.
Tasks are configured as [Beam::Runnable](https://metacpan.org/pod/Beam::Runnable) objects by [Beam::Wire](https://metacpan.org/pod/Beam::Wire)
container files.
# SUBROUTINES
## enqueue
Beam::Minion->enqueue( $container_name, $task_name, \@args, \%opt );
Enqueue the task named `$task_name` from the container named `$container_name`.
The `BEAM_MINION` environment variable must be set.
`\%opt` is a hash reference with the following keys:
- attempts
Number of times to retry this job if it fails. Defaults to `1`.
- delay
Time (in seconds) to delay this job (from now). Defaults to `0`.
- priority
The job priority. Higher priority jobs get performed first. Defaults to `0`.
(These are the same options allowed in [the Minion "enqueue"
method](http://mojolicious.org/perldoc/Minion#enqueue1))
# GETTING STARTED
## Configure Minion
To start running your [Beam::Runner](https://metacpan.org/pod/Beam::Runner) jobs, you must first start
a [Minion](https://metacpan.org/pod/Minion) worker with the [beam minion
worker.command](https://metacpan.org/pod/Beam::Minion::Command::worker). Minion requires
a database to coordinate workers, and communicates with this database
using a [Minion::Backend](https://metacpan.org/pod/Minion::Backend).
The supported Minion backends are:
- [Minion::Backend::SQLite](https://metacpan.org/pod/Minion::Backend::SQLite) - `sqlite:`
- [Minion::Backend::Pg](https://metacpan.org/pod/Minion::Backend::Pg) - `postgresql://:@/`
- [Minion::Backend::mysql](https://metacpan.org/pod/Minion::Backend::mysql) - `mysql://:@/`
- [Minion::Backend::MongoDB](https://metacpan.org/pod/Minion::Backend::MongoDB) - `mongodb://:`
Once you've picked a database backend, configure the `BEAM_MINION`
environment variable with the URL. Minion will automatically deploy the
database tables it needs, so be sure to allow the right permissions (if
the database has such things).
In order to communicate with Minion workers on other machines, it will
be necessary to use a database accessible from the network (so, not
SQLite).
## Start a Worker
Once the `BEAM_MINION` environment variable is set, you can start
a worker with `beam minion worker`. Each worker can run jobs from
all the containers it can find from the `BEAM_PATH` environment
variable. Each worker will run up to 4 jobs concurrently.
## Spawn a Job
Jobs are spawned with `beam minion run `.
The `service` must be an object that consumes the [Beam::Runnable](https://metacpan.org/pod/Beam::Runnable)
role. `container` should be a path to a container file and can be
an absolute path, a path relative to the current directory, or a
path relative to one of the paths in the `BEAM_PATH` environment
variable (separated by `:`).
You can queue up jobs before you have workers running. As soon as
a worker is available, it will start running jobs from the queue.
# SEE ALSO
[Beam::Wire](https://metacpan.org/pod/Beam::Wire), [Beam::Runner](https://metacpan.org/pod/Beam::Runner), [Minion](https://metacpan.org/pod/Minion)
# AUTHOR
Doug Bell
# CONTRIBUTOR
Mohammad S Anwar
# COPYRIGHT AND LICENSE
This software is copyright (c) 2018 by Doug Bell.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
