Uid Server

From Spire Trading Inc.
Revision as of 19:43, 27 May 2026 by Kamal (talk | contribs) (Created page with "The Uid Server is a centralized service responsible for generating batches of unique integers that can be used to identify items, such as database entries. The Uid Server regi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Uid Server is a centralized service responsible for generating batches of unique integers that can be used to identify items, such as database entries. The Uid Server registers itself with the Service Locator as a uid_server and ensures uniqueness by tracking allocated identifiers in a MySQL database.

Configuration

The Uid Server is configured via a YAML file with three top-level sections: data_store, server, and service_locator. 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:
  # The network interface and port the Uid Server binds to.
  interface: "0.0.0.0:20900"
  # List of addresses the server advertises for client connections.
  addresses: ["192.168.1.100:20900", "0.0.0.0:20900"]

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

A Python script automates configuration file generation. Usage:

  --local 0.0.0.0                   # Local interface (default: auto-detected IP)
  --world 192.168.1.100             # Global interface (default: same as local)
  --address 127.0.0.1:20000         # Service Locator address
  --password [REQUIRED]             # Admin password for Service Locator
  --mysql_address 127.0.0.1:3306    # MySQL server address
  --mysql_username admin            # MySQL username (default: spireadmin)
  --mysql_password [OPTIONAL]       # MySQL password (default: same as admin password)
  --mysql_schema uid_db             # Database schema (default: spire)

The script:

  • Generates config.yml from config.default.yml template.
  • Requires only the --password argument by default.

Logging

Log files are generated as srv_[YYYY][MM][DD]_[HH]_[MM]_[SS].log in the runtime directory. Upon termination, non-empty log files are moved into the log/ subfolder, while empty log files are deleted.

Management

The Uid Server is managed through three core scripts:

  • start.sh - Starts the Uid Server. Does nothing if the server is already running.
  • stop.sh - Stops an existing server instance and waits for the server to terminate.
  • check.sh - Verifies that the server is running and reports its status.