Spaces:
Running
Running
configurable GATEWAY_PORT, safer Jupyter token, browser/DBus fixes,
Browse filesStartup robustness: configurable GATEWAY_PORT, safer Jupyter token, browser/DBus fixes, AUTO_DOCTOR toggle
- iframe-fix.cjs +3 -2
- start.sh +20 -5
iframe-fix.cjs
CHANGED
|
@@ -19,9 +19,10 @@ http.Server.prototype.emit = function (event, ...args) {
|
|
| 19 |
if (event === "request") {
|
| 20 |
const [, res] = args;
|
| 21 |
|
| 22 |
-
// Only intercept on the main OpenClaw server (
|
|
|
|
| 23 |
const serverPort = this.address && this.address() && this.address().port;
|
| 24 |
-
if (serverPort && serverPort !==
|
| 25 |
return origEmit.apply(this, [event, ...args]);
|
| 26 |
}
|
| 27 |
|
|
|
|
| 19 |
if (event === "request") {
|
| 20 |
const [, res] = args;
|
| 21 |
|
| 22 |
+
// Only intercept on the main OpenClaw server (respects GATEWAY_PORT env var)
|
| 23 |
+
const expectedPort = Number(process.env.GATEWAY_PORT || 7860);
|
| 24 |
const serverPort = this.address && this.address() && this.address().port;
|
| 25 |
+
if (serverPort && serverPort !== expectedPort) {
|
| 26 |
return origEmit.apply(this, [event, ...args]);
|
| 27 |
}
|
| 28 |
|
start.sh
CHANGED
|
@@ -509,7 +509,16 @@ inject_provider_models_from_env "github-copilot" "GITHUB_COPILOT_MODELS" "COPILO
|
|
| 509 |
|
| 510 |
# Browser configuration (managed local Chromium in HF/Docker)
|
| 511 |
BROWSER_EXECUTABLE_PATH=""
|
| 512 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 513 |
if [ -x "$candidate" ]; then
|
| 514 |
if file "$candidate" 2>/dev/null | grep -q "ELF"; then
|
| 515 |
BROWSER_EXECUTABLE_PATH="$candidate"
|
|
@@ -581,9 +590,11 @@ if [ "$BROWSER_SHOULD_ENABLE" = "true" ]; then
|
|
| 581 |
"localLaunchTimeoutMs": 45000,
|
| 582 |
"localCdpReadyTimeoutMs": 30000,
|
| 583 |
"extraArgs": [
|
|
|
|
|
|
|
|
|
|
| 584 |
"--disable-dev-shm-usage",
|
| 585 |
"--disable-gpu",
|
| 586 |
-
"--disable-setuid-sandbox",
|
| 587 |
"--no-first-run",
|
| 588 |
"--disable-background-networking",
|
| 589 |
"--disable-sync",
|
|
@@ -844,8 +855,12 @@ graceful_shutdown() {
|
|
| 844 |
}
|
| 845 |
trap graceful_shutdown SIGTERM SIGINT
|
| 846 |
|
|
|
|
| 847 |
warmup_browser() {
|
| 848 |
[ "$BROWSER_SHOULD_ENABLE" = "true" ] || return 0
|
|
|
|
|
|
|
|
|
|
| 849 |
|
| 850 |
(
|
| 851 |
sleep 8
|
|
@@ -1623,9 +1638,9 @@ while true; do
|
|
| 1623 |
if [ "${AUTO_DOCTOR:-false}" = "true" ]; then
|
| 1624 |
openclaw doctor --fix || true
|
| 1625 |
fi
|
| 1626 |
-
echo "Launching OpenClaw gateway on port
|
| 1627 |
|
| 1628 |
-
GATEWAY_ARGS=(gateway run --port
|
| 1629 |
if [ "${GATEWAY_VERBOSE:-0}" = "1" ]; then
|
| 1630 |
GATEWAY_ARGS+=(--verbose)
|
| 1631 |
echo "Gateway verbose logging enabled (GATEWAY_VERBOSE=1)"
|
|
@@ -1644,7 +1659,7 @@ while true; do
|
|
| 1644 |
GATEWAY_READY_TIMEOUT="${GATEWAY_READY_TIMEOUT:-90}"
|
| 1645 |
ready=false
|
| 1646 |
for ((i=0; i<GATEWAY_READY_TIMEOUT; i++)); do
|
| 1647 |
-
if (echo > /dev/tcp/127.0.0.1/
|
| 1648 |
ready=true
|
| 1649 |
break
|
| 1650 |
fi
|
|
|
|
| 509 |
|
| 510 |
# Browser configuration (managed local Chromium in HF/Docker)
|
| 511 |
BROWSER_EXECUTABLE_PATH=""
|
| 512 |
+
# On Debian/Ubuntu, /usr/bin/chromium is a shell wrapper; the real ELF binary
|
| 513 |
+
# lives at /usr/lib/chromium/chromium. Check the real binary first, then fall
|
| 514 |
+
# back to wrapper scripts (which are also valid executablePath values for
|
| 515 |
+
# Playwright/OpenClaw — they re-exec the real binary internally).
|
| 516 |
+
for candidate in \
|
| 517 |
+
/usr/lib/chromium/chromium \
|
| 518 |
+
/usr/lib/chromium-browser/chromium-browser \
|
| 519 |
+
/usr/bin/chromium \
|
| 520 |
+
/usr/bin/chromium-browser \
|
| 521 |
+
/snap/bin/chromium; do
|
| 522 |
if [ -x "$candidate" ]; then
|
| 523 |
if file "$candidate" 2>/dev/null | grep -q "ELF"; then
|
| 524 |
BROWSER_EXECUTABLE_PATH="$candidate"
|
|
|
|
| 590 |
"localLaunchTimeoutMs": 45000,
|
| 591 |
"localCdpReadyTimeoutMs": 30000,
|
| 592 |
"extraArgs": [
|
| 593 |
+
"--no-sandbox",
|
| 594 |
+
"--disable-setuid-sandbox",
|
| 595 |
+
"--no-zygote",
|
| 596 |
"--disable-dev-shm-usage",
|
| 597 |
"--disable-gpu",
|
|
|
|
| 598 |
"--no-first-run",
|
| 599 |
"--disable-background-networking",
|
| 600 |
"--disable-sync",
|
|
|
|
| 855 |
}
|
| 856 |
trap graceful_shutdown SIGTERM SIGINT
|
| 857 |
|
| 858 |
+
BROWSER_WARMED_UP=false
|
| 859 |
warmup_browser() {
|
| 860 |
[ "$BROWSER_SHOULD_ENABLE" = "true" ] || return 0
|
| 861 |
+
# Only warm up once — gateway restarts should not re-spawn new warmup jobs.
|
| 862 |
+
[ "$BROWSER_WARMED_UP" = "false" ] || return 0
|
| 863 |
+
BROWSER_WARMED_UP=true
|
| 864 |
|
| 865 |
(
|
| 866 |
sleep 8
|
|
|
|
| 1638 |
if [ "${AUTO_DOCTOR:-false}" = "true" ]; then
|
| 1639 |
openclaw doctor --fix || true
|
| 1640 |
fi
|
| 1641 |
+
echo "Launching OpenClaw gateway on port ${GATEWAY_PORT}..."
|
| 1642 |
|
| 1643 |
+
GATEWAY_ARGS=(gateway run --port "${GATEWAY_PORT}" --bind lan)
|
| 1644 |
if [ "${GATEWAY_VERBOSE:-0}" = "1" ]; then
|
| 1645 |
GATEWAY_ARGS+=(--verbose)
|
| 1646 |
echo "Gateway verbose logging enabled (GATEWAY_VERBOSE=1)"
|
|
|
|
| 1659 |
GATEWAY_READY_TIMEOUT="${GATEWAY_READY_TIMEOUT:-90}"
|
| 1660 |
ready=false
|
| 1661 |
for ((i=0; i<GATEWAY_READY_TIMEOUT; i++)); do
|
| 1662 |
+
if (echo > /dev/tcp/127.0.0.1/${GATEWAY_PORT}) 2>/dev/null; then
|
| 1663 |
ready=true
|
| 1664 |
break
|
| 1665 |
fi
|