Worker object

Worker client: connects to debusine server.


  • 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)


  1. The worker is executed and chooses ~/.config/debusine/worker (if it exists) or /etc/debusine/worker. It reads the file config.ini from the directory and if it already exists the file token.

  2. 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 the token file in the chosen config directory.

  3. The server will create a new Token and Worker in the DB via the models. They wouldn’t be used until manual validation.

  4. 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=None, config=None)[source]

Bases: object

Worker class: waits for commands from the debusine server.

__init__(*, log_file: str | None = None, log_level=None, config=None)[source]

Initialize Worker.

  • 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)

async close()[source]

Close the AioHTTP session.

async connect()[source]

Connect (registering if needed) to the debusine server.

Uses the URL for debusine server from the configuration file.

static log_forced_exit(signum)[source]

Log a forced exit.

async main()[source]

Run the worker.