Launcher UI redesign + server mirror sync + file download optimization
This commit is contained in:
+39
-1
@@ -15,7 +15,8 @@ def parse_args():
|
||||
mode_group.add_argument("--dev", action="store_true", help="Development mode with auto-reload")
|
||||
mode_group.add_argument("--prod", action="store_true", help="Production mode with 4 workers")
|
||||
mode_group.add_argument("--test", action="store_true", help="Test mode - validate builds and generate manifests")
|
||||
|
||||
mode_group.add_argument("--sync", action="store_true", help="Sync mode - sync with main server as mirror")
|
||||
|
||||
# Additional options
|
||||
parser.add_argument("--host", default="0.0.0.0", help="Host to bind to (default: 0.0.0.0)")
|
||||
parser.add_argument("--port", type=int, default=1582, help="Port to bind to (default: 1582)")
|
||||
@@ -53,6 +54,43 @@ async def run_test_mode():
|
||||
logger.info("All packs validated successfully")
|
||||
sys.exit(0)
|
||||
|
||||
async def run_sync_mode():
|
||||
"""Sync with main server as mirror"""
|
||||
import os
|
||||
|
||||
main_url = os.environ.get("MAIN_SERVER_URL")
|
||||
if not main_url:
|
||||
logger.error("MAIN_SERVER_URL not set. Run: MAIN_SERVER_URL=http://main:1582 python cli.py --sync")
|
||||
sys.exit(1)
|
||||
|
||||
logger.info(f"Starting mirror sync from {main_url}")
|
||||
|
||||
# Get version from main
|
||||
import httpx
|
||||
async with httpx.AsyncClient() as client:
|
||||
# Get version
|
||||
try:
|
||||
resp = await client.get(f"{main_url}/launcher/version")
|
||||
data = resp.json()
|
||||
version = data.get("version")
|
||||
logger.info(f"Main server version: {version}")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to get version from main: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
# Get sync manifest
|
||||
try:
|
||||
resp = await client.get(f"{main_url}/launcher/sync/{version}")
|
||||
sync_data = resp.json()
|
||||
logger.info(f"Files to sync: {len(sync_data.get('files', []))}")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to get sync manifest: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
# Sync happens during server startup in mirror mode
|
||||
# Just verify we can reach main
|
||||
logger.info("Mirror sync configured. Server will sync on startup.")
|
||||
|
||||
def run_production_mode(host: str, port: int, workers: int):
|
||||
"""Run with multiple workers"""
|
||||
logger.info(f"Starting in PRODUCTION mode with {workers} workers on {host}:{port}")
|
||||
|
||||
Reference in New Issue
Block a user