sheppyd — the launch supervisor
sheppyd is Sheppy’s local supervisor daemon. It owns the actual node
processes: it spawns them, watches them, stops and restarts them, and reports
their live state back to the TUI and the CLI. Everything in Sheppy that
runs something runs it through sheppyd.
The daemon lets your nodes keep running after the TUI exits. You can launch
them, quit the TUI (or lose your SSH connection), and come back later to find
them still running and still under sheppy’s control. If sheppyd itself is
killed, the nodes keep running, and the next daemon to start re-adopts them.
Scope.
sheppydruns every node on the machine it runs on. An alternative’smachine:only chooses whichros_setupgets sourced; nothing starts on another host. Multi-machine supervision is on the roadmap.This guide covers the daemon itself. For commands see the CLI reference, for what the screen shows see TUI, and for problems see Troubleshooting.
Design: the clients do the work
sheppyd never reads a manifest, a profile, or any YAML. The TUI and CLI
handle all of that.
sheppy TUI ──┐ ┌─────────────────────────────┐
├── client lib ──── unix ─────│ sheppyd │
sheppy CLI ──┘ (resolver + socket │ process table + spawner │
protocol) NDJSON │ stdlib only; no yaml, no │
│ manifest, no textual │
└─────────────────────────────┘- Clients (the TUI and the
sheppyCLI) read the manifest and the active profile, and resolve each selected node into a finalLaunchSpec: a descriptor — plain data giving the exact argv to start and how to supervise it — plus the node name and its parameters (for display). sheppydis a durable process table. It receives aLaunchSpec, runs exactly what the descriptor says, watches the result, and reports state. It has no opinion about what the process is.
Consequences worth knowing:
- The daemon imports only the Python standard library — not even a YAML parser. It is small enough to read end to end.
- Manifest schema changes never touch the daemon.
- How a node’s
kind(executable/launch_file/process/docker) becomes a command is entirely a client-side concern (see Launch resolution).
Lifecycle
Auto-spawn
You never have to start sheppyd by hand. The first action that needs it —
pressing space on a node in the TUI, or running sheppy up — spawns the
daemon detached and waits for its socket. Browsing and editing profiles never
spawn a daemon; only an actual launch does.
You can also manage it explicitly:
sheppy daemon status # is it running? how many nodes does it supervise?
sheppy daemon stop # shut the daemon down (children keep running)Single instance
Only one sheppyd runs per home directory. This is enforced with an
flock lock file; a second sheppyd invocation exits immediately with
sheppyd: already running. A stale socket file left by a crashed daemon is
detected and replaced.
Shutdown leaves children running
Stopping the daemon (sheppy daemon stop, or SIGTERM/SIGINT to the
process) does not stop the nodes. The daemon exits; the children keep
running. This is deliberate: restarting the supervisor must never take the
robot down. To stop everything, use sheppy down, which stops every node
first and then stops the daemon.
Survivability and re-adoption
sheppyd mirrors its process table to a small JSON state file on every
change. When a daemon starts, it reads that file and re-adopts any child whose
PID is still alive and whose /proc start-time still matches the recorded
value (so a recycled PID is never mistaken for the original process). Adopted
processes can be stopped, restarted, and queried exactly like ones the current
daemon launched.
One consequence of re-adoption: because the daemon is no longer the parent of
an adopted child, it cannot read that child’s exit code. Adopted processes
therefore report exit_code: null when they terminate.
Zero idle cost
sheppyd is event-driven. With no client subscribed it runs no periodic
timers at all — it wakes only for socket traffic and child-exit events. The
per-node CPU/RSS sampler runs only while at least one client is subscribed,
and stops the moment the last subscriber disconnects. This matters on
resource-starved machines: an idle daemon uses almost no CPU.
Node states
Every supervised node is in exactly one state: stopped, launching, running, stopping, or crashed. The TUI’s glyph legend shows how each one looks.
A node is launching until it survives launch_grace seconds; a process
that exits inside that window (for example, a bad package name) is reported as
crashed rather than flickering through running.
Stopping is an escalation
A stop sends SIGINT to the child’s whole process group (this is what
ros2 launch expects for a clean shutdown), waits stop_grace seconds, then
escalates to SIGTERM, waits kill_grace seconds, and finally SIGKILL.
Each child leads its own process group, so the entire process tree is
signalled — not just the direct child.
Crashes are flagged, never auto-restarted
If a node exits on its own, sheppyd marks it crashed, records the exit
code (or the terminating signal), and leaves it stopped. It does not
restart it. Restarting is an operator decision (r in the TUI, or
sheppy restart <node>). Automatic restart-on-crash is intentionally not
implemented.
Logs
Each node’s stdout and stderr are written directly to a per-run log file — the child holds the file descriptor, so the daemon never sits between a node and its output. (This is also why the daemon crashing can’t disturb a running node: there is no pipe to break.)
~/.sheppy/logs/<node>/<YYYYmmdd-HHMMSS>-<id>.logEach launch gets its own file; the last keep_runs (default 5) files per node
are kept and older ones are pruned. The daemon also keeps an in-memory
ring buffer of the last ring_lines (default 300) lines per node as a
tail view over the current file — this is what sheppy logs and the TUI’s
PROCESS tab display, including a crashed node’s last output.
The daemon’s own log lives at ~/.sheppy/logs/sheppyd.log.
Configuration
Optional, at ~/.sheppy/sheppyd.json. It is a single flat JSON object —
plain keys, no nesting — read once at startup. Every key is optional; unknown
keys are ignored with a warning in the daemon log. A missing or malformed file
falls back to defaults.
{
"log_dir": "~/.sheppy/logs",
"ring_lines": 300,
"keep_runs": 5,
"coredumps": false,
"usage_interval": 2.0,
"launch_grace": 2.0,
"stop_grace": 5.0,
"kill_grace": 5.0
}| Key | Default | Meaning |
|---|---|---|
log_dir | <home>/logs | where per-node log files are written |
ring_lines | 300 | lines kept in the in-memory tail per node |
keep_runs | 5 | per-run log files retained per node |
coredumps | false | if true, raise each child’s core-dump limit |
usage_interval | 2.0 | seconds between CPU/RSS samples (while watched) |
launch_grace | 2.0 | seconds a node must survive to be running |
stop_grace | 5.0 | seconds after SIGINT before SIGTERM |
kill_grace | 5.0 | seconds after SIGTERM before SIGKILL |
Home directory
Everything sheppyd owns lives under ~/.sheppy by default. Set the
SHEPPY_HOME environment variable to relocate it (this is also how the test
suite isolates daemons). The unix socket is placed in $XDG_RUNTIME_DIR/sheppy/
when that is available and SHEPPY_HOME is unset; otherwise it sits directly
under the home directory. The socket is created mode 0600 and its directory
0700. A unix socket path can be at most 107 bytes, so a deeply nested
SHEPPY_HOME stops sheppyd from starting; it prints the reason and exits.
Launch resolution
Clients turn a manifest alternative into a LaunchSpec before handing it to
the daemon. Each kind is a launcher discovered through the
sheppy.launchers entry-point group, not a hardcoded list, so plugins can add
more (see Writing a launcher plugin). The kinds sheppy
ships with:
kind | Source | Resolved command |
|---|---|---|
executable | core | ros2 run <package> <executable> --ros-args -p k:=v … |
launch_file | core | ros2 launch <package> <launch_file> k:=v … |
process | core | the command string, run verbatim |
docker | plugin | docker run -d … from an inline container: or a translated compose: service, then supervised through docker wait / docker stop / docker logs |
For the three core kinds, if the alternative’s machine declares a
ros_setup, the command is prefixed with source <ros_setup> &&, and the
whole thing is run as bash -c "<command>". Every value drawn from the
manifest — package names, parameter values, everything — is shell-quoted when
the command is composed, so a stray quote or shell metacharacter in a
parameter value can’t break out of the command.
The daemon runs that command with its own environment and working directory, both inherited from the terminal that started it. See ROS integration.
Parameters on a process-kind alternative are ignored (with a warning) —
there’s no ROS argument convention to map them onto.
Protocol
Clients talk to sheppyd over the unix socket using newline-delimited JSON
(NDJSON) — one JSON object per line, so it’s debuggable by hand with
nc -U <socket>. On connect the daemon sends a hello:
{"event": "hello", "sheppyd": "0.1", "protocol": 1}Requests carry an id; the matching reply echoes it and carries ok:
→ {"id": 3, "op": "launch", "spec": {"node": "sim_gui", "alt_id": "unreal", "params": {}, "descriptor": {"supervise": "inherit", "start": ["bash", "-c", "/opt/sim/UnrealEditor MyProject -game"]}}}
← {"id": 3, "ok": true}A spec without a descriptor is rejected. The request above is the
sim_gui node from examples/sheppy-manifest.yaml, resolved by the client.
op | Effect |
|---|---|
launch | start spec.descriptor; replaces any process already running for that node (one process per node) |
stop | begin the stop escalation for a node |
restart | stop, then relaunch the same spec |
status | return the full table: per node {state, pid, exit_code, started_at, usage, spec} |
logs | return the last n ring-buffer lines for a node |
subscribe | receive pushed status events for every state change and usage tick until the connection closes |
shutdown | daemon exits; children keep running |
A malformed line, an unknown op, an unknown node, or a handler error produces an error reply — it never takes the daemon down.
Limitations
- Local only. Every launch runs on this machine.
machine:only chooses whichros_setupgets sourced. - No auto-restart. Crashed nodes stay crashed until you restart them.
- No adoption of foreign processes.
sheppydonly supervises what it (or a previoussheppyd) started. A node started by hand in another terminal is invisible to it.