diff options
Diffstat (limited to 'app/backends/servers.py')
| -rw-r--r-- | app/backends/servers.py | 16 |
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) |
