feat: portable Windows data layout and launcher package
Separate persistent user data from application code (data/work_tracker.db, data/uploads, data/storage) with idempotent legacy migration and SQLite integrity checks. Add offline packaging scripts for a Windows x11 x64 portable ZIP (embeddable Python, Start/Stop/Backup.bat). Fix launcher: no multiline python -c in BAT and no os.dup2 — uvicorn runs detached with wvt.log; health wait and busy-port diagnostics included.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""Print launch diagnostics when /health did not answer.
|
||||
|
||||
Usage: diagnose_start.py <port> <wvt.log> <pidfile>
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def tail(path: Path, n: int = 30) -> str:
|
||||
try:
|
||||
text = path.read_text(encoding="utf-8", errors="replace")
|
||||
except Exception as exc:
|
||||
return f"(cannot read {path}: {exc})"
|
||||
lines = text.splitlines()
|
||||
return "\n".join(lines[-n:])
|
||||
|
||||
|
||||
def main() -> int:
|
||||
port = sys.argv[1] if len(sys.argv) > 1 else "?"
|
||||
log = Path(sys.argv[2]) if len(sys.argv) > 2 else Path("wvt.log")
|
||||
pidfile = Path(sys.argv[3]) if len(sys.argv) > 3 else Path("wvt.pid")
|
||||
crash = log.parent / "wvt-crash.log"
|
||||
|
||||
print(f"port={port}")
|
||||
if pidfile.is_file():
|
||||
pid = pidfile.read_text(encoding="utf-8", errors="replace").strip()
|
||||
print(f"pidfile={pidfile} pid={pid or '(empty)'}")
|
||||
if pid.isdigit():
|
||||
import subprocess
|
||||
|
||||
out = subprocess.run(
|
||||
["tasklist", "/FI", f"PID eq {pid}"],
|
||||
capture_output=True,
|
||||
)
|
||||
print(out.stdout.decode("utf-8", errors="replace").strip() or "(tasklist empty)")
|
||||
else:
|
||||
print(f"pidfile={pidfile} (missing)")
|
||||
|
||||
print(f"--- tail {log} ---")
|
||||
print(tail(log))
|
||||
if crash.is_file():
|
||||
print(f"--- {crash} ---")
|
||||
print(tail(crash, 40))
|
||||
else:
|
||||
print(f"--- {crash} (missing) ---")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user