- Complete Flask-based control panel for multi-tenant POS instances - Dashboard with global stats, system health, and recent demos - Demo provisioning in 1 click with auto-expiration tracking - Tenant management: activate/deactivate, reset data, delete - Health monitoring: PostgreSQL, Redis, disk, memory, systemd services - Migration orchestration UI for running schema updates across all tenants - JWT authentication with manager_users table - Dark theme SPA frontend with real-time search and actions - systemd service file included
51 lines
2.9 KiB
Python
51 lines
2.9 KiB
Python
"""Nexus Instance Manager — Configuration."""
|
|
import os
|
|
|
|
# ─── Database ──────────────────────────────────────────────────────────────
|
|
MASTER_DB_URL = os.environ.get("MASTER_DB_URL") or os.environ.get("DATABASE_URL")
|
|
if not MASTER_DB_URL:
|
|
raise ValueError(
|
|
"MASTER_DB_URL environment variable is required. "
|
|
"Example: postgresql://user:pass@localhost/nexus_autoparts"
|
|
)
|
|
|
|
TENANT_DB_URL_TEMPLATE = os.environ.get("TENANT_DB_URL_TEMPLATE")
|
|
if not TENANT_DB_URL_TEMPLATE:
|
|
raise ValueError(
|
|
"TENANT_DB_URL_TEMPLATE environment variable is required. "
|
|
"Example: postgresql://user:pass@localhost/{db_name}"
|
|
)
|
|
|
|
# ─── Security ──────────────────────────────────────────────────────────────
|
|
MANAGER_JWT_SECRET = os.environ.get("MANAGER_JWT_SECRET")
|
|
if not MANAGER_JWT_SECRET:
|
|
raise ValueError(
|
|
"MANAGER_JWT_SECRET environment variable is required. "
|
|
"Generate one with: python3 -c 'import secrets; print(secrets.token_hex(32))'"
|
|
)
|
|
|
|
MANAGER_JWT_EXPIRES = int(os.environ.get("MANAGER_JWT_EXPIRES", "28800")) # 8 hours
|
|
|
|
# Internal API key for manager-to-POS operations
|
|
INTERNAL_API_KEY = os.environ.get("INTERNAL_API_KEY", "")
|
|
|
|
# ─── Demo Settings ─────────────────────────────────────────────────────────
|
|
DEMO_DEFAULT_DAYS = int(os.environ.get("DEMO_DEFAULT_DAYS", "14"))
|
|
DEMO_DEFAULT_PIN = os.environ.get("DEMO_DEFAULT_PIN", "0000")
|
|
DEMO_SUBDOMAIN_PREFIX = os.environ.get("DEMO_SUBDOMAIN_PREFIX", "demo")
|
|
|
|
# ─── Services Health Check ─────────────────────────────────────────────────
|
|
POS_URL = os.environ.get("POS_URL", "http://127.0.0.1:5001/pos/health")
|
|
DASHBOARD_URL = os.environ.get("DASHBOARD_URL", "http://127.0.0.1:5000/")
|
|
QUART_URL = os.environ.get("QUART_URL", "http://127.0.0.1:5002/")
|
|
REDIS_URL = os.environ.get("REDIS_URL", "redis://localhost:6379/0")
|
|
|
|
# ─── Paths ─────────────────────────────────────────────────────────────────
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
POS_DIR = os.environ.get("POS_DIR", "/home/Autopartes/pos")
|
|
MIGRATIONS_DIR = os.path.join(POS_DIR, "migrations")
|
|
|
|
# ─── App Identity ──────────────────────────────────────────────────────────
|
|
APP_NAME = "Nexus Instance Manager"
|
|
APP_VERSION = "1.0.0"
|