Skip to main content

Module kill_helpers

Module kill_helpers 

Source
Expand description

Shared kill-by-lock-owner logic for the {api,db,mcp,viewer} kill commands.

A server’s identity on disk is the lockfile it holds: the api at <dir>/bin/locks key api (machine-wide, one lock), and db / mcp / viewer at <dir>/state/<state>/locks keyed db / mcp / viewer (per state). Killing a server means reading the live owner PIDs of that lockfile via objectiveai_sdk::lockfile::owners and terminating them — for db, killing the supervisor takes the postmaster with it (job object / PR_SET_PDEATHSIG).

Functions§

kill_lock_owners
Read the owner PIDs of (locks_dir, key) and kill each. Returns the count actually terminated. A lockfile with no live owner yields zero — idempotent.
kill_per_state
Kill the per-state lockfile owners for key across the scope: --state hits only the current OBJECTIVEAI_STATE; --global fans out across every <dir>/state/<name>/locks concurrently and sums the kills.