Worker

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 /ws/1.0/worker/connect)

Flow

  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 /ws/1.0/worker/connect to wait for commands to execute.

Objects documentation

class debusine.worker.Worker(*, log_file: Optional[str] = None, log_level=None, config=None)[source]

Worker class: waits for commands from the debusine server.

DEFAULT_LOG_LEVEL = 20
__init__(*, log_file: Optional[str] = None, log_level=None, config=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)

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.