Dmitry Beresnev commited on
Commit Β·
fdc7a1e
1
Parent(s): 0337912
fix gateway token
Browse files- app.py +5 -2
- scripts/bootstrap_gateway_token.py +36 -0
- supervisord.conf +1 -1
app.py
CHANGED
|
@@ -558,12 +558,15 @@ with std_ui_status_col:
|
|
| 558 |
except Exception:
|
| 559 |
proxy_ok = False
|
| 560 |
|
| 561 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
| 562 |
st.markdown(
|
| 563 |
f"Gateway Via Proxy ({OPENCLAW_PROXY_LOCAL_URL}): "
|
| 564 |
f"{'π’' if proxy_ok else 'π΄'} {proxy_status}"
|
| 565 |
)
|
| 566 |
-
st.caption(f"URL: {std_ui_url}")
|
| 567 |
if OPENCLAW_STANDARD_UI_PUBLIC_URL:
|
| 568 |
st.caption(f"Public URL: {OPENCLAW_STANDARD_UI_PUBLIC_URL}")
|
| 569 |
|
|
|
|
| 558 |
except Exception:
|
| 559 |
proxy_ok = False
|
| 560 |
|
| 561 |
+
st.markdown(
|
| 562 |
+
f"Gateway Local ({mask_token_in_url(std_ui_url)}): "
|
| 563 |
+
f"{'π’' if local_ok else 'π΄'} {local_status}"
|
| 564 |
+
)
|
| 565 |
st.markdown(
|
| 566 |
f"Gateway Via Proxy ({OPENCLAW_PROXY_LOCAL_URL}): "
|
| 567 |
f"{'π’' if proxy_ok else 'π΄'} {proxy_status}"
|
| 568 |
)
|
| 569 |
+
st.caption(f"URL: {mask_token_in_url(std_ui_url)}")
|
| 570 |
if OPENCLAW_STANDARD_UI_PUBLIC_URL:
|
| 571 |
st.caption(f"Public URL: {OPENCLAW_STANDARD_UI_PUBLIC_URL}")
|
| 572 |
|
scripts/bootstrap_gateway_token.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def main() -> int:
|
| 7 |
+
token = os.getenv("OPENCLAW_GATEWAY_TOKEN", "").strip()
|
| 8 |
+
if not token:
|
| 9 |
+
return 0
|
| 10 |
+
|
| 11 |
+
state_path = Path("/app/.openclaw/state/openclaw.json")
|
| 12 |
+
state_path.parent.mkdir(parents=True, exist_ok=True)
|
| 13 |
+
|
| 14 |
+
data = {}
|
| 15 |
+
if state_path.exists():
|
| 16 |
+
try:
|
| 17 |
+
data = json.loads(state_path.read_text(encoding="utf-8"))
|
| 18 |
+
except Exception:
|
| 19 |
+
data = {}
|
| 20 |
+
|
| 21 |
+
gateway = data.get("gateway", {})
|
| 22 |
+
if not isinstance(gateway, dict):
|
| 23 |
+
gateway = {}
|
| 24 |
+
auth = gateway.get("auth", {})
|
| 25 |
+
if not isinstance(auth, dict):
|
| 26 |
+
auth = {}
|
| 27 |
+
auth["token"] = token
|
| 28 |
+
gateway["auth"] = auth
|
| 29 |
+
data["gateway"] = gateway
|
| 30 |
+
|
| 31 |
+
state_path.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8")
|
| 32 |
+
return 0
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
if __name__ == "__main__":
|
| 36 |
+
raise SystemExit(main())
|
supervisord.conf
CHANGED
|
@@ -5,7 +5,7 @@ pidfile=/tmp/supervisord.pid
|
|
| 5 |
user=root
|
| 6 |
|
| 7 |
[program:openclaw]
|
| 8 |
-
command=/bin/sh -lc "openclaw gateway run --port 18789 --allow-unconfigured --dev"
|
| 9 |
autorestart=true
|
| 10 |
startsecs=5
|
| 11 |
startretries=20
|
|
|
|
| 5 |
user=root
|
| 6 |
|
| 7 |
[program:openclaw]
|
| 8 |
+
command=/bin/sh -lc "python /app/scripts/bootstrap_gateway_token.py && openclaw gateway run --port 18789 --allow-unconfigured --dev"
|
| 9 |
autorestart=true
|
| 10 |
startsecs=5
|
| 11 |
startretries=20
|