Skip to content

Architecture

Dealer is a monolithic gevent process: one Bottle WSGI app, two RabbitMQ consumer stacks, and twenty provider worker classes loaded at import time.

Entry point

src/dealer/server.py
  ├── gevent monkey.patch_all()
  ├── Bottle app merges dealer routes from controllers.py
  └── __main__: gevent pywsgi server on --port

There is no main.py — always run src/dealer/server.py.

Package layout

src/dealer/
  config/cfg.py           # fs_config loader (import time)
  server.py               # WSGI entry
  main/
    controllers.py        # HTTP routes; constructs stacks on import
    paths.py              # SETTINGS dict, LOGGING_PATH
    api/
      provider_stack.py   # Priority + buffer queue consumers
      tasks_stack.py      # Tasks queue consumer
      workers/            # One class per ad provider
      tasks_handlers/     # dealer, email, sms, s3, db, chatgpt
      datastore/          # MySQL + Redis helpers
      common/             # Rabbit listener, logging

Runtime flow

flowchart LR
    Client[HTTP client] -->|POST /put| Controllers
    Controllers -->|permission check| Redis
    Controllers -->|enqueue| RabbitMQ
    RabbitMQ --> ProviderStack
    RabbitMQ --> TasksStack
    ProviderStack --> Workers[Provider workers]
    Workers --> spapi[skynet-provider-api]
    Workers --> MySQL
    TasksStack --> Handlers[Task handlers]
  1. HTTP — POST /put validates user permissions (Redis/MySQL settings), publishes a JSON job to the priority queue or buffer queue.
  2. ProviderStack — gevent pool pulls messages, dispatches to the worker class registered for the provider name in the payload.
  3. TasksStack — separate queue (tasks) for automation messages typed dealer, email, sms, s3, db, chatgpt.

Configuration

SETTINGS in main/paths.py is built from config/cfg.py constants at import. See Configuration & secrets.

Deploy shape

CodeDeploy (appspec.yml + scripts/after_install) installs to /srv/skynet-dealer/, writes .env, and configures supervisor to run run_server.sh. No Docker image in this repository.