Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

Reuse service pid when command is unreadable

cyhbd0fde2a1743
diff --git a/tests/test_runtime_service_lock.py b/tests/test_runtime_service_lock.py
index bd189f104..1b89f932f 100644
--- a/tests/test_runtime_service_lock.py
+++ b/tests/test_runtime_service_lock.py
@@ -46,6 +46,20 @@ class RuntimeServiceLockTests(unittest.TestCase):
spawn_background.assert_called_once()
self.assertEqual(pid_path.read_text(encoding="utf-8"), "67890")
+ def test_start_service_reuses_live_pid_when_command_is_unreadable(self):
+ with tempfile.TemporaryDirectory() as tmpdir:
+ pid_path = Path(tmpdir) / "service.pid"
+ pid_path.write_text("12345", encoding="utf-8")
+
+ with patch("vibe.runtime.paths.get_runtime_pid_path", return_value=pid_path):
+ with patch("vibe.runtime.pid_alive", return_value=True):
+ with patch("vibe.runtime.get_process_command", return_value=None):
+ with patch("vibe.runtime.spawn_background") as spawn_background:
+ pid = runtime.start_service()
+
+ self.assertEqual(pid, 12345)
+ spawn_background.assert_not_called()
+
if __name__ == "__main__":
unittest.main()
diff --git a/vibe/runtime.py b/vibe/runtime.py
index 71db29ba4..d2dc9acc0 100644
--- a/vibe/runtime.py
+++ b/vibe/runtime.py
@@ -450,8 +450,15 @@ def _command_references_path(command: str | None, expected_path: Path) -> bool:
return False
-def _pid_matches_service(pid: int) -> bool:
- return _command_references_path(get_process_command(pid), get_service_main_path())
+def _pid_mismatches_service(pid: int) -> bool:
+ command = get_process_command(pid)
+ if not command:
+ logger.warning(
+ "Reusing existing service pid=%s because its command line could not be inspected",
+ pid,
+ )
+ return False
+ return not _command_references_path(command, get_service_main_path())
def render_status():
@@ -473,7 +480,7 @@ def start_service():
except Exception:
existing_pid = 0
if existing_pid and pid_alive(existing_pid):
- if _pid_matches_service(existing_pid):
+ if not _pid_mismatches_service(existing_pid):
return existing_pid
logger.warning(
"Ignoring stale service pid file pid=%s because it does not match the Vibe service",