Skip to content
广告 · 本站推荐广告

openclaw gateway

管理 OpenClaw API 网关的生命周期和配置。网关是外部请求进入 Agent 的统一入口。

命令签名

bash
openclaw gateway <子命> [选项]

子命令

子命令说明
start启动 API 网关
stop停止 API 网关
restart重启 API 网关
status查看网关运行状态

openclaw gateway start

启动 API 网关服务。

bash
openclaw gateway start [选项]
选项类型说明
--port <port>number监听端口(默认 18789
--host <host>string绑定地址(默认 localhost
--foregroundboolean前台运行(不进入后台)

openclaw gateway stop

停止正在运行的网关。

bash
openclaw gateway stop [--force]
选项类型说明
--forceboolean强制终止

openclaw gateway restart

重启网关,并重新加载配置。

bash
openclaw gateway restart

openclaw gateway status

查看网关的运行状态和连接信息。

bash
openclaw gateway status [--json]

输出示例:

Gateway Status:  running
Endpoint:        http://localhost:18789
Uptime:          1h 20m
Active Conns:    3
Total Requests:  1,247

前台与后台模式

  • 后台模式(默认)— 网关作为后台进程运行,由守护进程管理
  • 前台模式--foreground)— 日志直接输出到终端,适合调试
bash
# 前台运行,查看实时日志
openclaw gateway start --foreground

配置重载

restart 子命令会重新读取配置文件,应用最新的路由规则、CORS 设置等变更,无需手动停止再启动。

示例

bash
# 启动网关(默认端口)
openclaw gateway start

# 指定端口
openclaw gateway start --port 8080

# 绑定到所有网络接口
openclaw gateway start --host 0.0.0.0

# 前台运行(调试)
openclaw gateway start --foreground

# 查看状态
openclaw gateway status

# 重启(重载配置)
openclaw gateway restart

# 停止
openclaw gateway stop

WARNING

--host 设为 0.0.0.0 会将网关暴露到公网。生产环境请配合反向代理和 TLS 使用。

另请参阅

基于MIT协议开源 | 内容翻译自 官方文档,同步更新