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
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()