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) |
--foreground | boolean | 前台运行(不进入后台) |
openclaw gateway stop
停止正在运行的网关。
bash
openclaw gateway stop [--force]| 选项 | 类型 | 说明 |
|---|---|---|
--force | boolean | 强制终止 |
openclaw gateway restart
重启网关,并重新加载配置。
bash
openclaw gateway restartopenclaw 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 stopWARNING
将 --host 设为 0.0.0.0 会将网关暴露到公网。生产环境请配合反向代理和 TLS 使用。
另请参阅
openclaw daemon— 守护进程管理openclaw health— 健康检查openclaw config— 配置管理
