aboutsummaryrefslogtreecommitdiff
path: root/app/backends/servers.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-24 04:53:43 -0400
committerhistoria <historiavg@proton.me>2026-08-24 04:53:43 -0400
commit0512a932bbf3b87619b6a250f87eb7904d22d1f7 (patch)
treedd2b0eb45823c0690ad2bc86f5aa9be2771f5b17 /app/backends/servers.py
parent9fb2434dcc8a1ed7bd085b453859d473de64448a (diff)
downloadtts-audiobook-generator-0512a932bbf3b87619b6a250f87eb7904d22d1f7.tar.gz
feat: hide convert/config/start-stop menus if no valid installation
Diffstat (limited to 'app/backends/servers.py')
-rw-r--r--app/backends/servers.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/backends/servers.py b/app/backends/servers.py
index a5a6829..63f37ce 100644
--- a/app/backends/servers.py
+++ b/app/backends/servers.py
@@ -233,6 +233,22 @@ def stop(name: str) -> bool:
return killed
+def manages(specs) -> bool:
+ """True when any SPEC in the list was started (and is kept alive) by us.
+
+ A server counts as ours when ``start`` recorded a pid file for it and
+ that pid is still alive — the same ownership rule ``stop`` applies
+ before refusing ("not started by this tool"). Used by the backends'
+ ``detect()`` so the hub's status table can tag an up server as
+ "[remote]" when it was launched outside this tool.
+ """
+ for spec in specs:
+ pid = pid_for(spec.name)
+ if pid is not None and _pid_alive(pid):
+ return True
+ return False
+
+
def pid_for(name: str):
"""Return the recorded pid for NAME, or None when no pid file exists."""
pid_file = _pid_path(name)