8900 commited on
Update entrypoint.sh
Browse files- 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 |
-
#
|
|
|
|
| 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) -
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|