Hide Windows scheduler bot execution
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user