首页龙虾技能列表 › OpenClaw Gateway Fix (Linux) — 技能工具

OpenClaw Gateway Fix (Linux) — 技能工具

v1.1.0

[自动翻译] Fix and diagnose OpenClaw Gateway service issues on Linux. Use when the gateway service shows "disabled" status despite running, when `openclaw gatewa...

1· 58·0 当前·0 累计
by @maksmirnnov (Maks)·MIT-0
下载技能包
License
MIT-0
最后更新
2026/4/11
安全扫描
VirusTotal
可疑
查看报告
OpenClaw
安全
high confidence
The skill's instructions and required actions are consistent with its stated purpose (diagnosing and fixing a user-scoped systemd gateway service); it makes no network calls or secret requests, but it does modify systemd unit files and shell/profile files so run carefully and back up config files first.
评估建议
This appears coherent and appropriate for fixing a user-scoped systemd gateway service. Before running the supplied commands: 1) Inspect ~/.config/systemd/user/openclaw-gateway.service manually and back it up (cp ... unit.bak) — the python snippet will overwrite the file with no backup. 2) Prefer running the commands step-by-step rather than copy-pasting the whole block; verify the UID (/run/user/$(id -u)) is correct for your account (don't unintentionally point to root). 3) Writing /etc/profile...
详细分析 ▾
用途与能力
Name/description match the runtime instructions: all commands and file edits (systemd user unit, XDG_RUNTIME_DIR/DBUS vars, loginctl linger) are directly relevant to diagnosing and fixing user-scope systemd gateway status issues.
指令范围
Instructions operate on relevant local files (~/.config/systemd/user/openclaw-gateway.service, ~/.bashrc, /etc/profile.d) and run systemctl/loginctl/openclaw commands; this is within scope but the unit-file edit is performed in-place with no backup and the guide suggests writing /etc/profile.d which requires root — users should inspect the unit file and back it up before applying automated edits.
安装机制
Instruction-only skill with no install steps, downloads, or third-party packages. No code is written to disk by the skill itself beyond the edits the user runs locally.
凭证需求
The skill requests no environment variables or credentials. The environment manipulations it recommends (XDG_RUNTIME_DIR, DBUS_SESSION_BUS_ADDRESS) are appropriate for the stated problem.
持久化与权限
Skill does not request permanent platform privileges and always:false. However several recommended fixes require modifying per-user unit files and system profile scripts and enabling linger (loginctl enable-linger), which may require root or elevated privileges — ensure you understand and authorize those changes.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.1.02026/4/7

Improved Issue 1 fix: replaced fragile sed one-liner with idempotent Python script. Added 'Why' column to shell escalation table. Fixed Quick check command in diagnosis.md (broken || chain). Clarified UID path detection in Step 2. Minor wording improvements throughout.

● 可疑

安装命令 点击复制

官方npx clawhub@latest install openclaw-gateway-linux-fix
镜像加速npx clawhub@latest install openclaw-gateway-linux-fix --registry https://cn.clawhub-mirror.com

技能文档

Issue 1: Gateway shows "disabled" despite running

Symptom: openclaw status or openclaw gateway status shows disabled, but the service is actually running.

Root cause: The gateway process spawns systemctl --user is-enabled without XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS in its environment. Without these, systemd user bus is unreachable → "Failed to connect to bus: No medium found".

⚠️ Common wrong fix: Adding these vars to ~/.bashrc or shell environment does NOT help — the gateway daemon doesn't inherit your shell env.

Correct fix: Add the vars directly to the systemd unit file:

RUNTIME_DIR="/run/user/$(id -u)"
UNIT=~/.config/systemd/user/openclaw-gateway.service

# Append env vars after [Service] line (idempotent check first) grep -q "XDG_RUNTIME_DIR" "$UNIT" || python3 - "$UNIT" "$RUNTIME_DIR" <<'EOF' import sys, re unit, runtime = sys.argv[1], sys.argv[2] content = open(unit).read() insert = f"\nEnvironment=XDG_RUNTIME_DIR={runtime}\nEnvironment=DBUS_SESSION_BUS_ADDRESS=unix:path={runtime}/bus" content = re.sub(r'(\[Service\])', r'\1' + insert, content, count=1) open(unit, 'w').write(content) print("Unit file updated.") EOF

# Reload and restart safely systemctl --user daemon-reload nohup bash -c 'sleep 2 && systemctl --user restart openclaw-gateway' > /tmp/gw-restart.log 2>&1 & sleep 3 && openclaw gateway status

Expected result: Service: systemd (enabled)


Issue 2: Safe gateway restart

Problem: openclaw gateway restart and systemctl --user restart openclaw-gateway send SIGTERM to the gateway, which also kills the shell that ran the command.

Always use this pattern:

nohup bash -c 'sleep 2 && systemctl --user restart openclaw-gateway' > /tmp/gw-restart.log 2>&1 &

sleep 2 + & detaches the restart from the current process tree before the gateway shuts down.


Issue 3: openclaw gateway status shows "disabled" in SSH session

This is a separate issue from Issue 1 — the gateway itself works fine, but your shell session lacks XDG_RUNTIME_DIR.

Affected: sudo su (without -), non-login shells, cron, sudo openclaw.

Fix: Add to ~/.bashrc and /etc/profile.d/openclaw-env.sh:

export XDG_RUNTIME_DIR=/run/user/$(id -u)
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus

Shell escalation cheatsheet:

CommandResultWhy
sudo su -✅ worksFull login shell, reads .bashrc
sudo -i✅ worksLogin shell (if vars in .bashrc)
sudo su❌ failsNon-login shell, env not loaded
sudo openclaw❌ failsClean env, vars stripped by sudo

Issue 4: Service not persisting after reboot

OpenClaw runs as a user-scope systemd service (~/.config/systemd/user/), not system-scope. Without linger, user services stop when the last session closes.

loginctl enable-linger $(whoami)   # persist after logout
systemctl --user enable openclaw-gateway  # auto-start on boot

See references/diagnosis.md for a full diagnostic checklist.

数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务