Fix K8s deployment crash: ensure DB directory exists on startup
init_db() now creates the parent directory for the SQLite database file before connecting. Also sets HAPROXY_DB_FILE in the K8s deployment to /app/data/ since the container doesn't have /opt/haproxy/conf/. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -63,6 +63,11 @@ def init_db() -> None:
|
||||
Creates tables if they don't exist, then checks for existing
|
||||
JSON/map files to migrate data from.
|
||||
"""
|
||||
# Ensure parent directory exists for the database file
|
||||
db_dir = os.path.dirname(DB_FILE)
|
||||
if db_dir:
|
||||
os.makedirs(db_dir, exist_ok=True)
|
||||
|
||||
conn = get_connection()
|
||||
cur = conn.cursor()
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ spec:
|
||||
value: "/root/.ssh/id_rsa"
|
||||
- name: SSH_PORT
|
||||
value: "22"
|
||||
- name: HAPROXY_DB_FILE
|
||||
value: "/app/data/haproxy_mcp.db"
|
||||
- name: LOG_LEVEL
|
||||
value: "INFO"
|
||||
volumeMounts:
|
||||
|
||||
Reference in New Issue
Block a user