Skip to content

cli: restart bridge tmux session before systemd restart#128

Merged
benvinegar merged 1 commit into
mainfrom
bentlegen/restart-refreshes-bridge
Feb 22, 2026
Merged

cli: restart bridge tmux session before systemd restart#128
benvinegar merged 1 commit into
mainfrom
bentlegen/restart-refreshes-bridge

Conversation

@benvinegar
Copy link
Copy Markdown
Member

@benvinegar benvinegar commented Feb 22, 2026

Summary

  • update baudbot restart to explicitly kill the slack-bridge tmux session before restarting the systemd service
  • this ensures a detached/stale bridge process cannot survive and continue running old behavior after restart
  • keep behavior best-effort and distro-safe:
    • use sudo -u <agent> when available
    • fallback to runuser -u <agent> when sudo is unavailable

Tests

  • add bin/baudbot.test.sh coverage asserting restart path:
    • kills tmux session slack-bridge
    • then calls systemctl restart baudbot
  • ran: bash bin/baudbot.test.sh
  • ran: bash -n bin/baudbot

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 22, 2026

Greptile Summary

Ensures stale detached bridge tmux sessions are cleaned up before systemd restart. This prevents old bridge processes from surviving restarts and continuing to run outdated behavior.

  • Kills slack-bridge tmux session as baudbot_agent user before restarting systemd service
  • Uses distro-safe fallback: prefers sudo -u, falls back to runuser -u when sudo unavailable
  • All operations are best-effort with error suppression (2>/dev/null || true) to avoid blocking restart
  • Comprehensive test coverage validates execution order: tmux kill → systemctl restart

Confidence Score: 5/5

  • This PR is safe to merge with no identified risks
  • Addresses a legitimate race condition where stale bridge processes could survive restarts. Implementation follows distro-safe patterns already established in the codebase, includes comprehensive test coverage, and uses best-effort error handling to avoid blocking the restart flow.
  • No files require special attention

Important Files Changed

Filename Overview
bin/baudbot Added tmux session cleanup before systemd restart with distro-safe fallbacks (sudo/runuser)
bin/baudbot.test.sh Added comprehensive test coverage for restart flow, verifying tmux kill precedes systemctl restart

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[sudo baudbot restart] --> B{require_root check}
    B -->|not root| C[Exit: requires root]
    B -->|is root| D{has_systemd?}
    D -->|no| E[Exit: systemd not available]
    D -->|yes| F{tmux available?}
    F -->|no| K[systemctl restart baudbot]
    F -->|yes| G{sudo available?}
    G -->|yes| H[sudo -u baudbot_agent tmux kill-session -t slack-bridge]
    G -->|no| I{runuser available?}
    I -->|yes| J[runuser -u baudbot_agent -- tmux kill-session -t slack-bridge]
    I -->|no| K
    H --> K
    J --> K
    K --> L[End]
Loading

Last reviewed commit: e176372

@benvinegar benvinegar merged commit d57f2c7 into main Feb 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant