NAME

Beekeeper::WorkerPool - Start, restart or stop worker pools

VERSION

Version 0.09

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            Display this help and exit

DESCRIPTION

This module contains the core of the command line tool bkpr which is used to start, restart or stop worker pools of persistent Beekeeper::Worker processes which receive RPC requests from the message bus.

When started it daemonizes itself (unless --foreground option is passed) and forks all worker processes, then keeps monitoring those forked processes and immediately respawns 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 format is relaxed JSON, so it allows comments and trailing commas.

All worker pools running on the host must be declared into this 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" : { "worker_count" : 2 },
    },
}]

bus.config.json

All logical buses used by an application are defined into a file named bus.config.json which specifies the connection 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",
}]

AUTHOR

José Micó, jose.mico@gmail.com

COPYRIGHT AND LICENSE

Copyright 2015-2023 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.