Hide Windows scheduler bot execution
This commit is contained in:
@@ -11,6 +11,14 @@ PID_FILE = PROJECT / "logs" / "bot.pid"
|
||||
LOG_FILE = PROJECT / "logs" / "bot_stderr.log"
|
||||
|
||||
|
||||
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 _taskkill(pid: int) -> None:
|
||||
subprocess.run(["taskkill", "/PID", str(pid), "/F"], capture_output=True, text=True)
|
||||
|
||||
@@ -69,7 +77,7 @@ def _start_bot() -> int:
|
||||
|
||||
with open(LOG_FILE, "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