NAME
Beekeeper::WorkerPool - Manage worker pools
VERSION
Version 0.05
SYNOPSIS
$ bkpr --pool MyPool start
Starting pool of MyApp workers: beekeeper-MyPool.
$ bkpr --pool MyPool stop
Stopping pool of MyApp workers: beekeeper-MyPool.
$ bkpr --help
Usage: bkpr [options] {start|stop|restart|reload|check}
--foreground Run in foreground (do not daemonize)
--pool str Worker pool name (mandatory)
--user str Run as specified user
--group str Run as specified group
--config-dir str Path to directory containing config files
--debug Turn on workers debug flag
--help Shows this message
DESCRIPTION
This module contains the core of the command line tool bkpr
which is used to manage worker pools: it start, stop and monitor pools of persistent Beekeeper::Worker
processes which receive RPC requests from message bus.
When started it daemonize itself (unless --foreground
option is passed) and fork all worker processes, then monitor those forked processes and immediately respawn defunct ones.
CONFIGURATION
pool.config.json
Workers pools are defined into a file named pool.config.json
, which is searched for into ENV BEEKEEPER_CONFIG_DIR
, ~/.config/beekeeper
and /etc/beekeeper
. The file is in relaxed JSON format (so it allows comments and trailing commas).
All worker pools running on the host must be declared into the file, specifying which logical bus should be used and which services it will run.
Each entry define a worker pool. Required parameters are:
pool_id
An arbitrary identifier for the worker pool.
bus_id
An identifier of logical bus used by worker processes.
workers
A map of worker classes to (arbitrary) config hashes.
The following example defines "MyApp" as a pool of 2 MyApp::Worker
processes:
[{
"pool_id" : "MyApp",
"bus_id" : "backend",
"workers" : {
"MyApp::Worker" : { "workers_count" : 2 },
},
}]
bus.config.json
All logical buses used by your application are defined into a file named bus.config.json
and specify the conection parameters to the MQTT brokers that will service them.
Each entry define a logical bus. Required parameters are:
bus_id
: unique identifier of the logical bus (required)
bus_role
: specifies if the bus is acting as frontend or backend
host
: hostname or IP address of the broker
port
: port of the broker (default is 1883)
tls
: if set to true enables the use of TLS on broker connection
username
: username used to connect to the broker
password
: password used to connect to the broker
The following example defines the logical bus "backend":
[{
"bus_id" : "backend",
"host" : "10.0.0.1",
"user" : "username",
"pass" : "password",
"vhost" : "/backend",
}]
AUTHOR
José Micó, jose.mico@gmail.com
COPYRIGHT AND LICENSE
Copyright 2015-2021 José Micó.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language itself.
This software is distributed in the hope that it will be useful, but it is provided “as is” and without any express or implied warranties. For details, see the full text of the license in the file LICENSE.