Worker object
Worker client: connects to debusine server.
Overview
Registration (needed only once per worker): If the worker doesn’t have a token: it will generate it and register with the server (HTTP POST to
/api/1.0/worker/register
)The client will use this token to connect to the server (WebSocket to
/api/ws/1.0/worker/connect
)
Flow
The worker is executed and chooses
~/.config/debusine/worker
(if it exists) or/etc/debusine/worker
. It reads the fileconfig.ini
from the directory and if it already exists the filetoken
.If there isn’t a token the worker generates one (using
secrets.token_hex()
) and registers it to the Debusine server via HTTP POST to /api/1.0/worker/register sending the generated token and the worker’s FQDN. The token is saved to thetoken
file in the chosen config directory.The server will create a new Token and Worker in the DB via the models. They wouldn’t be used until manual validation.
The client can then connect using WebSockets to
/api/ws/1.0/worker/connect
and wait for commands to execute.
Objects documentation
- class debusine.worker.Worker(*, log_file: str | None = None, log_level: str | None = None, worker_type: ~typing.Literal[<WorkerType.EXTERNAL: 'external'>, <WorkerType.SIGNING: 'signing'>] = WorkerType.EXTERNAL, config: debusine.worker.config.ConfigHandler | None = None)[source]
Bases:
object
Worker class: waits for commands from the debusine server.
- DEFAULT_LOG_LEVEL = 20
- __init__(*, log_file: str | None = None, log_level: str | None = None, worker_type: ~typing.Literal[<WorkerType.EXTERNAL: 'external'>, <WorkerType.SIGNING: 'signing'>] = WorkerType.EXTERNAL, config: debusine.worker.config.ConfigHandler | None = None) None [source]
Initialize Worker.
- Parameters:
log_file – log file to where the logs are saved. If None uses settings from config.ini or default’s Python (stderr).
log_level – minimum level of the logs being saved. If None uses settings from config.ini or DEFAULT_LOG_LEVEL.
config – ConfigHandler to use (or creates a default one)