Beekeeper::WorkerPool - Manage worker pools
Version 0.06
$ 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
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.
--foreground
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).
pool.config.json
BEEKEEPER_CONFIG_DIR
~/.config/beekeeper
/etc/beekeeper
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.
pool_id
bus_id An identifier of logical bus used by worker processes.
bus_id
workers A map of worker classes to (arbitrary) config hashes.
workers
The following example defines "MyApp" as a pool of 2 MyApp::Worker processes:
MyApp::Worker
[{ "pool_id" : "MyApp", "bus_id" : "backend", "workers" : { "MyApp::Worker" : { "workers_count" : 2 }, }, }]
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.
bus.config.json
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
bus_role
host: hostname or IP address of the broker
host
port: port of the broker (default is 1883)
port
tls: if set to true enables the use of TLS on broker connection
tls
username: username used to connect to the broker
username
password: password used to connect to the broker
password
The following example defines the logical bus "backend":
[{ "bus_id" : "backend", "host" : "10.0.0.1", "user" : "username", "pass" : "password", }]
José Micó, jose.mico@gmail.com
jose.mico@gmail.com
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.
To install Beekeeper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Beekeeper
CPAN shell
perl -MCPAN -e shell install Beekeeper
For more information on module installation, please visit the detailed CPAN module installation guide.