From bfd8984f3818905bea2e5671f9bdf13a34d9abfb Mon Sep 17 00:00:00 2001 From: brockdarnold Date: Sun, 14 Jun 2026 15:15:17 +0000 Subject: [PATCH] publish update.py --- update.py | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/update.py b/update.py index c93cc1a..8974cdc 100644 --- a/update.py +++ b/update.py @@ -170,11 +170,36 @@ def ensure_tesseract(cfg_path): print(f"• Tesseract ready: {path}") +def _kill_scripts(names): + """Force-stop pythonw processes whose command line names any of `names`.""" + if not WIN: + return + pats = " -or ".join(f"$_.CommandLine -like '*{n}*'" for n in names) + ps("Get-CimInstance Win32_Process -Filter \"Name='pythonw.exe'\" | " + f"Where-Object {{ {pats} }} | " + "ForEach-Object { Stop-Process -Id $_.ProcessId -Force }") + + +def _start_script(name): + if not WIN: + return + ps(f"Start-Process pythonw -ArgumentList '\"{os.path.join(HERE, name)}\"' " + f"-WorkingDirectory '{HERE}' -WindowStyle Hidden") + + +def restart_mining_watchers(): + """Restart only the data watchers (not the autoupdate poller) — used by the + poller to bring the watchers onto freshly-pulled code without killing itself.""" + _kill_scripts(WATCHER_SCRIPTS) + for n in WATCHER_SCRIPTS: + _start_script(n) + + def watchers_running(): if not WIN: return 0 _, out = ps("(Get-CimInstance Win32_Process -Filter \"Name='pythonw.exe'\" " - "| Where-Object { $_.CommandLine -like '*watcher*' }).Count") + "| Where-Object { $_.CommandLine -like '*eve_*' }).Count") try: return int(out or "0") except ValueError: @@ -182,9 +207,8 @@ def watchers_running(): def stop_watchers(): - ps("Get-CimInstance Win32_Process -Filter \"Name='pythonw.exe'\" | " - "Where-Object { $_.CommandLine -like '*watcher*' } | " - "ForEach-Object { Stop-Process -Id $_.ProcessId -Force }") + # all of ours run as pythonw on an eve_*.py script (watchers + autoupdate poller) + _kill_scripts(("eve_",)) def start_watchers(cfg_path):