fix(@scripts): 🐛 improve detached session handling with systemd scope
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
d145983188
commit
d4359d4d56
1 changed files with 9 additions and 1 deletions
10
bin/rclaude
10
bin/rclaude
|
|
@ -1603,9 +1603,17 @@ inner=$(build_inner "$dir")
|
|||
# background and print the session name. Symmetric with the local-host
|
||||
# detached branch above; used by supervisor processes (e.g. clare web)
|
||||
# that bring up a remote Claude pane without attaching the calling tty.
|
||||
#
|
||||
# We wrap `tmux new-session -d` in `systemd-run --user --scope --collect`
|
||||
# so the tmux server is parented to its own systemd scope, not the ssh
|
||||
# login session's scope. Without this, systemd-logind reaps the tmux
|
||||
# server when the ssh session ends — even with `loginctl enable-linger`,
|
||||
# transient ssh-spawn scopes get cleaned up after disconnect. The
|
||||
# `--collect` flag lets systemd garbage-collect the scope after exit.
|
||||
# Mosh is interactive-only — always go through ssh for detached spawn.
|
||||
if [ -n "${RCLAUDE_DETACHED:-}" ]; then
|
||||
ssh $_SSH_LIVE_OPTS "$host" "tmux new-session -d -s '${session}' \"${inner}\""
|
||||
_remote_cmd="systemd-run --user --scope --collect --quiet tmux new-session -d -s '${session}' \"${inner}\" 2>/dev/null || tmux new-session -d -s '${session}' \"${inner}\""
|
||||
ssh $_SSH_LIVE_OPTS "$host" "$_remote_cmd"
|
||||
printf '%s\n' "$session"
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue