Created
January 23, 2026 19:16
-
-
Save josancamon19/6ef0d0b013dc3683990763728692cc7f to your computer and use it in GitHub Desktop.
clawdbot-gateway.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # clawdbot-gateway.sh - Ensure clawdbot gateway is running in detached tmux session | |
| SESSION="clawdbot-gw" | |
| CLAWDBOT="/.sprite/languages/node/nvm/versions/node/v22.20.0/bin/clawdbot" | |
| # Check if gateway is responding | |
| check_gateway() { | |
| "$CLAWDBOT" gateway health &>/dev/null | |
| return $? | |
| } | |
| # Kill existing gateway processes | |
| kill_gateway() { | |
| # Kill tmux session if exists | |
| tmux kill-session -t "$SESSION" 2>/dev/null | |
| # Kill any stray gateway processes | |
| pkill -f "clawdbot.*gateway.*run" 2>/dev/null | |
| sleep 1 | |
| } | |
| # Start gateway in detached tmux | |
| start_gateway() { | |
| tmux new-session -d -s "$SESSION" "$CLAWDBOT gateway run --dev 2>&1 | tee /tmp/clawdbot-gateway.log" | |
| echo "Started gateway in tmux session '$SESSION'" | |
| } | |
| # Main logic | |
| if check_gateway; then | |
| echo "Gateway is already running and healthy." | |
| exit 0 | |
| fi | |
| echo "Gateway not running or unhealthy. Starting..." | |
| kill_gateway | |
| start_gateway | |
| # Wait for gateway to come up | |
| for i in {1..10}; do | |
| sleep 1 | |
| if check_gateway; then | |
| echo "Gateway is up and running!" | |
| echo " - Logs: /tmp/clawdbot-gateway.log" | |
| echo " - Attach: tmux attach -t $SESSION" | |
| echo " - Dashboard: http://127.0.0.1:18789/" | |
| exit 0 | |
| fi | |
| echo "Waiting for gateway... ($i/10)" | |
| done | |
| echo "Gateway failed to start. Check logs: /tmp/clawdbot-gateway.log" | |
| exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment