Spaces:
Running
Running
Update start.sh
Browse files
start.sh
CHANGED
|
@@ -3,6 +3,7 @@ set -euo pipefail
|
|
| 3 |
|
| 4 |
export PROXY_PORT="${PROXY_PORT:-7860}"
|
| 5 |
export OPENCLAW_PORT="${OPENCLAW_PORT:-8080}"
|
|
|
|
| 6 |
export PORT="${OPENCLAW_PORT}"
|
| 7 |
export HOST="0.0.0.0"
|
| 8 |
export OPENCLAW_HOST="0.0.0.0"
|
|
@@ -249,6 +250,24 @@ PY
|
|
| 249 |
|
| 250 |
/app/sync-root-data.sh loop &
|
| 251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
run_openclaw() {
|
| 253 |
while true; do
|
| 254 |
echo "Starting OpenClaw on 127.0.0.1:${OPENCLAW_PORT}..."
|
|
@@ -269,17 +288,14 @@ run_openclaw() {
|
|
| 269 |
|
| 270 |
run_nginx() {
|
| 271 |
while true; do
|
| 272 |
-
envsubst '${PROXY_PORT} ${OPENCLAW_PORT} ${OPENCLAW_GATEWAY_PASSWORD}'
|
|
|
|
| 273 |
nginx -c /tmp/nginx.conf -g 'daemon off;'
|
| 274 |
echo "Nginx exited; restarting in 2 seconds..."
|
| 275 |
sleep 2
|
| 276 |
done
|
| 277 |
}
|
| 278 |
|
| 279 |
-
run_openclaw &
|
| 280 |
-
run_nginx &
|
| 281 |
-
|
| 282 |
-
# Start a simple webhook server if OpenClaw doesn't start one
|
| 283 |
run_simple_webhook() {
|
| 284 |
while true; do
|
| 285 |
echo "Starting simple webhook server on port 8787..."
|
|
@@ -292,35 +308,43 @@ run_simple_webhook() {
|
|
| 292 |
done
|
| 293 |
}
|
| 294 |
|
|
|
|
|
|
|
|
|
|
| 295 |
|
| 296 |
# Wait for services to start
|
| 297 |
echo "Waiting for services to start..."
|
| 298 |
sleep 10
|
| 299 |
|
| 300 |
-
# Check
|
| 301 |
echo "Checking webhook port 8787..."
|
| 302 |
if command -v ss &> /dev/null && ss -tuln 2>/dev/null | grep -q ":8787"; then
|
| 303 |
echo "Webhook server is listening on port 8787"
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
curl -s -o /dev/null -w "Webhook test status: %{http_code}\n" http://0.0.0.0:8787/tg-webhook || curl -s -o /dev/null -w "Webhook test status: %{http_code}\n" http://localhost:8787/tg-webhook || echo "Webhook test failed"
|
| 307 |
-
elif sleep 2 && curl -s http://0.0.0.0:8787/tg-webhook &>/dev/null; then
|
| 308 |
echo "Webhook server is accessible on port 8787"
|
| 309 |
else
|
| 310 |
-
echo "WARNING: Webhook server is NOT listening on port 8787"
|
| 311 |
-
echo "Starting simple webhook server as fallback..."
|
| 312 |
run_simple_webhook &
|
| 313 |
fi
|
| 314 |
|
| 315 |
-
# Check
|
| 316 |
echo "Checking OpenClaw port ${OPENCLAW_PORT}..."
|
| 317 |
if command -v ss &> /dev/null && ss -tuln 2>/dev/null | grep -q ":${OPENCLAW_PORT}"; then
|
| 318 |
echo "OpenClaw is listening on port ${OPENCLAW_PORT}"
|
| 319 |
-
elif
|
| 320 |
echo "OpenClaw is accessible on port ${OPENCLAW_PORT}"
|
| 321 |
else
|
| 322 |
echo "WARNING: OpenClaw is NOT listening on port ${OPENCLAW_PORT}"
|
| 323 |
fi
|
| 324 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
wait -n
|
| 326 |
-
exit 1
|
|
|
|
| 3 |
|
| 4 |
export PROXY_PORT="${PROXY_PORT:-7860}"
|
| 5 |
export OPENCLAW_PORT="${OPENCLAW_PORT:-8080}"
|
| 6 |
+
export CODE_PORT="${CODE_PORT:-8888}"
|
| 7 |
export PORT="${OPENCLAW_PORT}"
|
| 8 |
export HOST="0.0.0.0"
|
| 9 |
export OPENCLAW_HOST="0.0.0.0"
|
|
|
|
| 250 |
|
| 251 |
/app/sync-root-data.sh loop &
|
| 252 |
|
| 253 |
+
# ── code-server (VS Code) ─────────────────────────────────────────────────────
|
| 254 |
+
run_code_server() {
|
| 255 |
+
mkdir -p /root/.config/code-server
|
| 256 |
+
cat > /root/.config/code-server/config.yaml <<YAML
|
| 257 |
+
bind-addr: 127.0.0.1:${CODE_PORT}
|
| 258 |
+
auth: password
|
| 259 |
+
password: ${OPENCLAW_GATEWAY_PASSWORD}
|
| 260 |
+
cert: false
|
| 261 |
+
YAML
|
| 262 |
+
while true; do
|
| 263 |
+
echo "Starting code-server on 127.0.0.1:${CODE_PORT}..."
|
| 264 |
+
code-server --config /root/.config/code-server/config.yaml /root/workspace
|
| 265 |
+
echo "code-server exited; restarting in 2 seconds..."
|
| 266 |
+
sleep 2
|
| 267 |
+
done
|
| 268 |
+
}
|
| 269 |
+
# ─────────────────────────────────────────────────────────────────────────────
|
| 270 |
+
|
| 271 |
run_openclaw() {
|
| 272 |
while true; do
|
| 273 |
echo "Starting OpenClaw on 127.0.0.1:${OPENCLAW_PORT}..."
|
|
|
|
| 288 |
|
| 289 |
run_nginx() {
|
| 290 |
while true; do
|
| 291 |
+
envsubst '${PROXY_PORT} ${OPENCLAW_PORT} ${OPENCLAW_GATEWAY_PASSWORD} ${CODE_PORT}' \
|
| 292 |
+
< /app/nginx.conf.template > /tmp/nginx.conf
|
| 293 |
nginx -c /tmp/nginx.conf -g 'daemon off;'
|
| 294 |
echo "Nginx exited; restarting in 2 seconds..."
|
| 295 |
sleep 2
|
| 296 |
done
|
| 297 |
}
|
| 298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
run_simple_webhook() {
|
| 300 |
while true; do
|
| 301 |
echo "Starting simple webhook server on port 8787..."
|
|
|
|
| 308 |
done
|
| 309 |
}
|
| 310 |
|
| 311 |
+
run_openclaw &
|
| 312 |
+
run_code_server &
|
| 313 |
+
run_nginx &
|
| 314 |
|
| 315 |
# Wait for services to start
|
| 316 |
echo "Waiting for services to start..."
|
| 317 |
sleep 10
|
| 318 |
|
| 319 |
+
# Check webhook port
|
| 320 |
echo "Checking webhook port 8787..."
|
| 321 |
if command -v ss &> /dev/null && ss -tuln 2>/dev/null | grep -q ":8787"; then
|
| 322 |
echo "Webhook server is listening on port 8787"
|
| 323 |
+
curl -s -o /dev/null -w "Webhook test status: %{http_code}\n" http://localhost:8787/tg-webhook || true
|
| 324 |
+
elif curl -s http://0.0.0.0:8787/tg-webhook &>/dev/null; then
|
|
|
|
|
|
|
| 325 |
echo "Webhook server is accessible on port 8787"
|
| 326 |
else
|
| 327 |
+
echo "WARNING: Webhook server is NOT listening on port 8787 — starting fallback..."
|
|
|
|
| 328 |
run_simple_webhook &
|
| 329 |
fi
|
| 330 |
|
| 331 |
+
# Check OpenClaw port
|
| 332 |
echo "Checking OpenClaw port ${OPENCLAW_PORT}..."
|
| 333 |
if command -v ss &> /dev/null && ss -tuln 2>/dev/null | grep -q ":${OPENCLAW_PORT}"; then
|
| 334 |
echo "OpenClaw is listening on port ${OPENCLAW_PORT}"
|
| 335 |
+
elif curl -s http://127.0.0.1:${OPENCLAW_PORT}/health &>/dev/null; then
|
| 336 |
echo "OpenClaw is accessible on port ${OPENCLAW_PORT}"
|
| 337 |
else
|
| 338 |
echo "WARNING: OpenClaw is NOT listening on port ${OPENCLAW_PORT}"
|
| 339 |
fi
|
| 340 |
|
| 341 |
+
# Check code-server port
|
| 342 |
+
echo "Checking code-server port ${CODE_PORT}..."
|
| 343 |
+
if command -v ss &> /dev/null && ss -tuln 2>/dev/null | grep -q ":${CODE_PORT}"; then
|
| 344 |
+
echo "code-server is listening on port ${CODE_PORT}"
|
| 345 |
+
else
|
| 346 |
+
echo "WARNING: code-server is NOT listening on port ${CODE_PORT}"
|
| 347 |
+
fi
|
| 348 |
+
|
| 349 |
wait -n
|
| 350 |
+
exit 1
|