8900 commited on
Commit
fd83f78
·
verified ·
1 Parent(s): 46912ea

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +14 -3
entrypoint.sh CHANGED
@@ -107,7 +107,8 @@ JSEOF
107
  # -- gateway loop -------------------------------------------------
108
 
109
  # Gateway exits on config save (OpenClaw full process restart).
110
- # Loop keeps container alive and restarts gateway in 2s.
 
111
 
112
  echo "[entrypoint] Starting gateway loop..."
113
  while true; do
@@ -117,6 +118,16 @@ while true; do
117
  --bind lan \
118
  --port 7860
119
  EXIT_CODE=$?
120
- echo "[entrypoint] Gateway exited (code $EXIT_CODE) - restarting in 2s..."
121
- sleep 2
 
 
 
 
 
 
 
 
 
 
122
  done
 
107
  # -- gateway loop -------------------------------------------------
108
 
109
  # Gateway exits on config save (OpenClaw full process restart).
110
+ # When OpenClaw restarts it spawns a child process then the parent exits.
111
+ # We must wait for port 7860 to be free before starting a new instance.
112
 
113
  echo "[entrypoint] Starting gateway loop..."
114
  while true; do
 
118
  --bind lan \
119
  --port 7860
120
  EXIT_CODE=$?
121
+ echo "[entrypoint] Gateway exited (code $EXIT_CODE) - waiting for port 7860 to clear..."
122
+ WAIT=0
123
+ while nc -z 127.0.0.1 7860 2>/dev/null; do
124
+ sleep 2
125
+ WAIT=$((WAIT+2))
126
+ if [ $WAIT -ge 60 ]; then
127
+ echo "[entrypoint] Port 7860 still in use after 60s - forcing restart anyway"
128
+ break
129
+ fi
130
+ done
131
+ echo "[entrypoint] Restarting gateway..."
132
+ sleep 1
133
  done