Uid Server

From Spire Trading Inc.
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 that defines its network interface, data store settings, and Service Locator integration. Below is the structure of the configuration file with example values:

---
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"]

data_store:
  # MySQL server address (host:port).
  address: "127.0.0.1:3306"

  # MySQL credentials.
  username: uid_server
  password: securepassword123
  schema: uid_db

service_locator:
  # Service Locator address for registration.
  address: "127.0.0.1:20000"

  # Uid Server credentials for Service Locator.
  username: uid_service
  password: adminpassword123
...

Installation & Setup

A Python script automates configuration file generation. Usage:

python setup.py
  --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)

Features:

  • Generates config.yml from config.default.yml template.
  • Requires only the --password argument by default.
  • Auto-detects local IP if --local is omitted.

Operations

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.

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.