fix: tray restart uses python -m for reliable process respawn
The previous os.execv approach and console_script detection both failed on Windows. Now restart always spawns `python -m media_server.main` via subprocess.Popen with start_new_session, which works regardless of how the server was originally started.
This commit is contained in:
@@ -277,6 +277,20 @@ def main():
|
||||
|
||||
# Tray exited — wait for server to finish graceful shutdown
|
||||
server_thread.join(timeout=10)
|
||||
|
||||
if tray.restart_requested:
|
||||
import subprocess
|
||||
|
||||
# Always restart via `python -m media_server.main` — this works
|
||||
# regardless of how we were originally started (console_script,
|
||||
# python -m, or direct script invocation).
|
||||
cmd = [sys.executable, "-m", "media_server.main"]
|
||||
|
||||
subprocess.Popen(
|
||||
cmd,
|
||||
cwd=Path.cwd(),
|
||||
start_new_session=True,
|
||||
)
|
||||
else:
|
||||
uvicorn.run(
|
||||
"media_server.main:app",
|
||||
|
||||
Reference in New Issue
Block a user