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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXxioW7HA18AY1gqnzA2HN
This commit is contained in:
1 parent
b3f023f6e2
commit
3ea83d568b
1 file changed
+8
-2
@@ -23,6 +23,10 @@ from pathlib import Path
|
|||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from zoneinfo import ZoneInfo
|
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
|
ROOT = Path(__file__).resolve().parent.parent
|
||||||
PG_BIN = Path(os.environ.get("PG_BIN", r"C:\Users\Admin\pgsql18\bin"))
|
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"))
|
OUT = Path(os.environ.get("LIVE_BACKUP_DIR", r"C:\Users\Admin\momentum-backups"))
|
||||||
@@ -44,9 +48,11 @@ def main() -> int:
|
|||||||
try:
|
try:
|
||||||
subprocess.run([str(PG_BIN / "pg_dump.exe"), "-h", u.hostname, "-p", str(PORT), "-U", u.username,
|
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)],
|
"-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)],
|
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]
|
missing = [m for m in MUST_HAVE if m not in listing]
|
||||||
if missing:
|
if missing:
|
||||||
raise RuntimeError(f"dump is missing {missing}")
|
raise RuntimeError(f"dump is missing {missing}")
|
||||||
|
|||||||
Reference in new issue
Block a user