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,32 @@
|
||||
"""Check whether TCP port is already in use on 127.0.0.1.
|
||||
|
||||
Exit codes:
|
||||
0 - port is busy
|
||||
1 - port is free
|
||||
2 - bad arguments
|
||||
"""
|
||||
import socket
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if len(sys.argv) != 2:
|
||||
print("usage: check_port.py <port>", file=sys.stderr)
|
||||
return 2
|
||||
try:
|
||||
port = int(sys.argv[1])
|
||||
except ValueError:
|
||||
print(f"bad port: {sys.argv[1]}", file=sys.stderr)
|
||||
return 2
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.settimeout(1.0)
|
||||
try:
|
||||
result = sock.connect_ex(("127.0.0.1", port))
|
||||
finally:
|
||||
sock.close()
|
||||
# connect_ex == 0 means something accepted the connection -> busy
|
||||
return 0 if result == 0 else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user