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:
kappa
2026-02-08 11:18:37 +09:00
parent cf554f3f89
commit e228fc02fb
2 changed files with 7 additions and 0 deletions

View File

@@ -63,6 +63,11 @@ def init_db() -> None:
Creates tables if they don't exist, then checks for existing Creates tables if they don't exist, then checks for existing
JSON/map files to migrate data from. 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() conn = get_connection()
cur = conn.cursor() cur = conn.cursor()

View File

@@ -41,6 +41,8 @@ spec:
value: "/root/.ssh/id_rsa" value: "/root/.ssh/id_rsa"
- name: SSH_PORT - name: SSH_PORT
value: "22" value: "22"
- name: HAPROXY_DB_FILE
value: "/app/data/haproxy_mcp.db"
- name: LOG_LEVEL - name: LOG_LEVEL
value: "INFO" value: "INFO"
volumeMounts: volumeMounts: