Skip to content

thuasta/saiblo-worker

 
 

Repository files navigation

saiblo-worker

A robust worker implementation for the Saiblo platform

Usage

Docker Deployment

The easiest way to get started is using our pre-built Docker image:

docker run -dit -e GAME_HOST_IMAGE=<your-game-host-image> -e NAME=<worker-name> --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock --rm ghcr.io/thuasta/saiblo-worker

Once launched, the worker will establish a connection to the Saiblo server and begin processing matches.

To build the image locally:

docker build -t saiblo-worker .

Manual Setup

  1. Ensure you have Docker 27.5 and Python 3.13 installed (other versions might work but aren't officially supported)

  2. Create a .env file with your configuration

  3. Install required packages:

    pip install -r requirements.txt
  4. Launch the worker:

    python main.py

Configuration

Worker Configuration

The following environment variables control the worker's behavior:

  • NAME: Worker identifier (required)

  • AGENT_BUILD_TIMEOUT: Agent build timeout in seconds (default: 300)

  • AGENT_CPUS: Agent container CPU allocation (default: 0.5)

  • AGENT_MEM_LIMIT: Agent container memory limit (default: 1g)

  • GAME_HOST_IMAGE: Game host container image name (required)

  • GAME_HOST_CPUS: Game host container CPU allocation (default: 1)

  • GAME_HOST_MEM_LIMIT: Game host container memory limit (default: 1g)

  • HTTP_BASE_URL: API endpoint base URL (default: https://api.dev.saiblo.net)

  • WEBSOCKET_URL: Saiblo WebSocket endpoint (default: wss://api.dev.saiblo.net/ws/)

  • JUDGE_TIMEOUT: Match duration limit in seconds (default: 600)

  • LOGGING_LEVEL: Logging verbosity level (default: INFO)

Container Setup

The worker automatically injects these environment variables:

Game host container:

  • TOKENS: Comma-separated player tokens

Agent container:

  • TOKEN: Player-specific token
  • GAME_HOST: Game host service address

Check out the examples directory for agent and game host image examples.

Match Results

After each match, the game host container must generate two files:

  • /app/data/result.json: Match outcome and statistics

    Example:

    {
       "scores": {
          "token_1": 1.14,
          "token_2": 5.14
       }
    }
  • /app/data/replay.dat: Binary replay data

The worker automatically processes these files and reports results to the Saiblo server.

Contributing

We welcome contributions! Feel free to submit pull requests.

License

AGPL-3.0-or-later © ASTA

About

A robust worker implementation for the Saiblo platform

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Python 99.0%
  • Other 1.0%