File size: 1,361 Bytes
48ecd01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #!/usr/bin/env bash
# start-gateway.sh โ OpenClaw ๊ฒ์ดํธ์จ์ด ์ง์ ์์ (๋
๋ฆฝ ํ๋ก์ธ์ค)
set -euo pipefail
RNTIER_HOME="${RNTIER_HOME:-$HOME}"
export PATH="${RNTIER_HOME}/.npm-global/bin:/usr/bin:/usr/local/bin:/bin:$PATH"
export HOME="${HOME:-/home/ghong}"
export OPENCLAW_STATE_DIR="${RNTIER_HOME}/.openclaw"
export OPENCLAW_CONFIG_PATH="${RNTIER_HOME}/.openclaw/openclaw.json"
LOG_DIR="/tmp/openclaw"
GATEWAY_LOG="${LOG_DIR}/gateway.log"
PID_FILE="/tmp/openclaw-gateway.pid"
mkdir -p "$LOG_DIR"
# ๊ธฐ์กด ํ๋ก์ธ์ค ์ ๋ฆฌ
pkill -f "openclaw.*gateway" 2>/dev/null || true
sleep 2
# ๊ฒ์ดํธ์จ์ด ์์ โ setsid๋ก ์์ ๋ถ๋ฆฌ
setsid nohup "${RNTIER_HOME}/.npm-global/bin/openclaw" gateway run \
--port 18789 \
--bind loopback \
>> "$GATEWAY_LOG" 2>&1 < /dev/null &
PID=$!
echo "$PID" > "$PID_FILE"
date +%s > /tmp/openclaw-last-restart
echo "[$(date)] Gateway launched with PID $PID"
# 10์ด ๋๊ธฐ ํ ์ํ ํ์ธ
sleep 10
if kill -0 "$PID" 2>/dev/null; then
echo "[$(date)] OK: Gateway PID $PID is alive"
ss -tlnH "sport = :18789" 2>/dev/null && echo "[$(date)] OK: Port 18789 is listening" || echo "[$(date)] WARN: Port 18789 not yet listening"
else
echo "[$(date)] FAIL: Gateway PID $PID died"
echo "--- Last 20 lines of gateway.log ---"
tail -20 "$GATEWAY_LOG" 2>/dev/null
exit 1
fi
|