feat: add systemd service config and install script
config/systemd/user/claude-sessions-save.service: source of truth for the shutdown service, version-controlled alongside the scripts it calls. scripts/install-systemd.sh: idempotent install script — copies the service file to ~/.config/systemd/user/, reloads the daemon, and enables + starts the service. Run on any new machine to wire up graceful Claude session shutdown.
This commit is contained in:
18
config/systemd/user/claude-sessions-save.service
Normal file
18
config/systemd/user/claude-sessions-save.service
Normal file
@@ -0,0 +1,18 @@
|
||||
[Unit]
|
||||
Description=Gracefully exit Claude Code sessions before shutdown
|
||||
Documentation=https://github.com/oreillyit/claude-foundations
|
||||
# Run before the system begins tearing down the session
|
||||
Before=shutdown.target halt.target reboot.target poweroff.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
# ExecStart is a no-op — the service exists purely for its ExecStop
|
||||
ExecStart=/bin/true
|
||||
# On stop (triggered at shutdown): gracefully exit all Claude tmux sessions
|
||||
ExecStop=%h/dev/claude/projects/claude-foundations/scripts/claude-sessions-shutdown
|
||||
# Allow up to 120s for Claude sessions to save and exit cleanly
|
||||
TimeoutStopSec=120
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
Reference in New Issue
Block a user