Administration Server

From Spire Trading Inc.
Revision as of 19:47, 27 May 2026 by Kamal (talk | contribs) (Created page with "The Administration Server manages account-level authorization and operational metadata for Spire. It maintains each account's role (trader, manager, administrator, or service)...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Administration Server manages account-level authorization and operational metadata for Spire. It maintains each account's role (trader, manager, administrator, or service), market-data entitlements, risk parameters, and trading permissions. By centralizing these attributes, it enforces access control, entitlement visibility, and trading eligibility across the system.

The server integrates with the Service Locator to enumerate accounts and with a MySQL database to persist administrative data.

Configuration

The Administration Server is configured via a YAML file with four top-level sections: data_store, server, service_locator, and entitlements. A grant_interval setting may also be specified. Below is the structure of the configuration file with example values:

data_store:
  # The address of the MySQL server.
  address: "127.0.0.1:3306"
  # The username used to authenticate with MySQL.
  username: spireadmin
  # The password for the MySQL user.
  password: [REQUIRED]
  # The name of the database schema where data is stored.
  schema: spire

server:
  # Primary network interface and port the Administration Server binds to.
  interface: "0.0.0.0:20100"
  # List of addresses the server is reachable at (for registration with Service Locator).
  # Typically includes both public-facing and local addresses.
  addresses: ["198.51.100.5:20100", "10.0.0.5:20100"]

service_locator:
  # The address of the Service Locator (host:port).
  address: "10.0.0.5:20000"
  # The account username used to authenticate with the Service Locator.
  username: administration_server
  # The password for the Service Locator account.
  password: [REQUIRED]

# Each entitlement specifies pricing, applicable exchanges, and message types.
entitlements:
  - name: "NYSE Basic"
    price: "10.00"
    currency: USD
    group: nyse_basic
    applicability:
      - venue: XNYS
        # source: the venue disseminating the market data
        source: XNYS
        messages: [BBO, TAS]

# Interval at which entitlement grants are reapplied (default: 1 hour).
grant_interval: 1h

A setup.py script is provided to generate the final config.yml. Usage:

  --local 0.0.0.0                   # Local interface (default: auto-detected IP)
  --world 198.51.100.5              # Global/public interface (optional)
  --address 10.0.0.5:20000          # Service Locator address (default: local_interface:20000)
  --password [REQUIRED]             # Admin password for Service Locator
  --mysql_address 127.0.0.1:3306    # MySQL server address
  --mysql_password secretpw         # MySQL password (default: --password if omitted)

A reset script (reset_risk_states.py) is provided to initialize or reset the risk state for all accounts and is typically run on a daily basis.

Management

The Administration Server is controlled using three operational scripts: start.sh, stop.sh, and check.sh.

start.sh

  • Exits immediately if the server is already running.
  • Creates a logs/ directory if necessary.
  • Moves any existing srv_*.log files into logs/.
  • Starts the AdministrationServer process in the background.
  • Reads network interfaces from config.yml and waits until the server is listening on at least one configured address.

This ensures the server is fully initialized before the script exits.

stop.sh

  • Sends SIGINT to request a graceful shutdown.
  • Waits for termination using exponential backoff (up to 300 seconds).
  • Sends SIGKILL if the server fails to stop cleanly.
  • Appends a forced-termination message to the most recent log file (if applicable).

This guarantees consistent shutdown behavior across normal and exceptional conditions.

check.sh

The check.sh script verifies whether the server is currently running by inspecting the PID recorded in pid.lock and testing whether the associated process exists.

Logging

Upon startup, older log files are moved into the logs/ directory.