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:
@@ -3,8 +3,6 @@
|
||||
import ctypes
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import webbrowser
|
||||
from pathlib import Path
|
||||
from typing import Callable
|
||||
@@ -125,10 +123,13 @@ class TrayManager:
|
||||
if not _confirm("Media Server", "Restart the server?"):
|
||||
return
|
||||
logger.info("Restart requested from tray")
|
||||
self._icon.stop()
|
||||
self._restart_requested = True
|
||||
self._on_exit()
|
||||
os.environ["MEDIA_SERVER_RESTART"] = "1"
|
||||
os.execv(sys.executable, [sys.executable] + sys.argv)
|
||||
self._icon.stop()
|
||||
|
||||
@property
|
||||
def restart_requested(self) -> bool:
|
||||
return getattr(self, "_restart_requested", False)
|
||||
|
||||
def _shutdown(self, icon: "pystray.Icon", item: "pystray.MenuItem") -> None:
|
||||
if not _confirm("Media Server", "Shut down the server?"):
|
||||
|
||||
Reference in New Issue
Block a user