From 3ea83d568bd487bad1471d96c18024f41f22be3b Mon Sep 17 00:00:00 2001 From: momentum dev Date: Thu, 8 Oct 2026 12:58:53 -0500 Subject: [PATCH] fix: run pg_dump/pg_restore windowless so closing a console cannot kill the nightly backup The LiveDbBackup task runs under pythonw, but pg_dump.exe is a console program, so Windows opened a visible console for it. On 2026-10-06 that window was closed and the dump died with 0xC000013A before writing a byte (the Ross recap died the same way ten minutes earlier). Pass CREATE_NO_WINDOW to both subprocess calls, the same fix the judge paper trader got in 7e6f881. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01LXxioW7HA18AY1gqnzA2HN --- deploy/backup_live_db.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/deploy/backup_live_db.py b/deploy/backup_live_db.py index ee1bf52..80b8963 100644 --- a/deploy/backup_live_db.py +++ b/deploy/backup_live_db.py @@ -23,6 +23,10 @@ from pathlib import Path from urllib.parse import urlparse from zoneinfo import ZoneInfo +# pg_dump/pg_restore are console programs: launched from pythonw they would pop a console window, +# and closing that window kills the dump (exit 0xC000013A, seen 2026-10-06). Run them windowless. +NO_WINDOW = getattr(subprocess, "CREATE_NO_WINDOW", 0) + ROOT = Path(__file__).resolve().parent.parent PG_BIN = Path(os.environ.get("PG_BIN", r"C:\Users\Admin\pgsql18\bin")) OUT = Path(os.environ.get("LIVE_BACKUP_DIR", r"C:\Users\Admin\momentum-backups")) @@ -44,9 +48,11 @@ def main() -> int: try: subprocess.run([str(PG_BIN / "pg_dump.exe"), "-h", u.hostname, "-p", str(PORT), "-U", u.username, "-d", u.path[1:], "-Fc", "-Z", "6", "-f", str(dump)], - env=env, check=True, capture_output=True, text=True, timeout=3600) + env=env, check=True, capture_output=True, text=True, timeout=3600, + creationflags=NO_WINDOW) listing = subprocess.run([str(PG_BIN / "pg_restore.exe"), "--list", str(dump)], - check=True, capture_output=True, text=True, timeout=600).stdout + check=True, capture_output=True, text=True, timeout=600, + creationflags=NO_WINDOW).stdout missing = [m for m in MUST_HAVE if m not in listing] if missing: raise RuntimeError(f"dump is missing {missing}")