Claude Code chats survive server restarts in a detachable host
A pipelines-claude-host process owns each claude -p CLI and its pipes, spools its stream-json output with offsets and serves a private Unix socket. The server detaches on shutdown and reattaches on start, replaying the spool to rebuild turns, approvals, questions, background tasks and the live model. Explicit close, idle release and CLI exit stop the host; a crashed host falls back to --resume with a notice.
This commit is contained in:
@@ -149,6 +149,10 @@ class Setup:
|
||||
content = (f"# {SERVICE_MARKER}\n[Unit]\nDescription=Pipelines native services\n"
|
||||
"\n[Service]\nType=simple\nExecStart=" + " ".join(map(quote, command))
|
||||
+ "\nRestart=on-failure\nRestartSec=5\nTimeoutStopSec=90\nUMask=0077\n"
|
||||
# The supervisor stops its own children. Only it is
|
||||
# signalled, so a Claude Code chat host (its own
|
||||
# session) outlives a restart as it does under launchd.
|
||||
"KillMode=process\n"
|
||||
"\n[Install]\nWantedBy=default.target\n").encode()
|
||||
path.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
self._write_atomic(path, content, 0o600)
|
||||
@@ -444,7 +448,9 @@ class Setup:
|
||||
|
||||
# --- build and skill -------------------------------------------------
|
||||
|
||||
COMMANDS = ("pipelines-server", "pipelines")
|
||||
# pipelines-claude-host keeps Claude Code chats alive across server
|
||||
# restarts; the server finds it next to its own executable.
|
||||
COMMANDS = ("pipelines-server", "pipelines", "pipelines-claude-host")
|
||||
|
||||
def build(self, prefix):
|
||||
"""Builds the server and CLI into bin/.next; install_binaries moves
|
||||
|
||||
Reference in New Issue
Block a user