Hide Windows scheduler bot execution

This commit is contained in:
whdwo
2026-07-02 16:06:14 +09:00
parent c43163629d
commit 80457fe6c4
5 changed files with 40 additions and 4 deletions
+9 -1
View File
@@ -17,6 +17,14 @@ from app.main import load_env
load_env()
def _bot_python() -> str:
if os.name == "nt":
pythonw = Path(sys.executable).with_name("pythonw.exe")
if pythonw.exists():
return str(pythonw)
return sys.executable
def _is_process_alive(pid: int) -> bool:
result = subprocess.run(
["tasklist", "/FI", f"PID eq {pid}", "/NH"],
@@ -69,7 +77,7 @@ def _restart_bot() -> int:
log_path = PROJECT / "logs" / "bot_stderr.log"
with open(log_path, "a", encoding="utf-8") as log:
proc = subprocess.Popen(
[sys.executable, "-u", "app/main.py"],
[_bot_python(), "-u", "app/main.py"],
cwd=PROJECT,
creationflags=creationflags,
stdout=log,