refactor: migrate data storage from JSON/map files to SQLite
Replace servers.json, certificates.json, and map file parsing with SQLite (WAL mode) as single source of truth. HAProxy map files are now generated from SQLite via sync_map_files(). Key changes: - Add db.py with schema, connection management, and JSON migration - Add DB_FILE config constant - Delegate file_ops.py functions to db.py - Refactor domains.py to use file_ops instead of direct list manipulation - Fix subprocess.TimeoutExpired not caught (doesn't inherit TimeoutError) - Add DB health check in health.py - Init DB on startup in server.py and __main__.py - Update all 359 tests to use SQLite-backed functions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import socket
|
||||
import select
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from .config import (
|
||||
@@ -161,7 +162,7 @@ def reload_haproxy() -> tuple[bool, str]:
|
||||
if result.returncode != 0:
|
||||
return False, f"Reload failed: {result.stderr}"
|
||||
return True, "OK"
|
||||
except TimeoutError:
|
||||
except (TimeoutError, subprocess.TimeoutExpired):
|
||||
return False, f"Command timed out after {SUBPROCESS_TIMEOUT} seconds"
|
||||
except FileNotFoundError:
|
||||
return False, "ssh/podman command not found"
|
||||
|
||||
Reference in New Issue
Block a user