CLIProxyAPI 管理
启动方式
CLIProxyAPI 支持两种启动方式:手动启动(调试用)和 systemd 守护(推荐,生产环境)。手动启动的进程 SSH 断开就没了,systemd 托管的进程会自动重启。
| 方式 | 命令 | 适用场景 |
|---|---|---|
| 手动启动 | cd /root/cliproxyapi && python main.py | 调试、临时测试 |
| systemd(user) | systemctl --user start cliproxyapi | 生产环境,当前用户作用域 |
| systemd(system) | systemctl start cliproxyapi | 生产环境,系统级守护 |
# 推荐:systemd user 模式管理
systemctl --user start cliproxyapi
systemctl --user status cliproxyapi --no-pager
systemctl --user restart cliproxyapi
# 查看实时日志
journalctl --user -u cliproxyapi -f
Systemd 服务安装
用 setup_cliproxy_service.sh 一键配置 systemd 服务,支持 --mode user(当前用户)和 --mode system(系统级)。推荐 user 模式,权限隔离更好。
# 安装 systemd 服务(user 模式,推荐)
./setup_cliproxy_service.sh --mode user
# 安装 systemd 服务(system 模式)
./setup_cliproxy_service.sh --mode system
# 安装后验证
systemctl --user status cliproxyapi --no-pager
OpenClaw Gateway 管理
Gateway 是 OpenClaw 的核心常驻进程,负责消息路由、任务调度、Provider 管理。它有一个致命特性:启动时缓存配置到内存,运行期间不会热加载。
# Gateway 常用操作
systemctl --user status openclaw-gateway.service --no-pager
systemctl --user restart openclaw-gateway.service
systemctl --user stop openclaw-gateway.service
# 改完配置后的标准流程
# 1. 编辑配置
# 2. 重启 Gateway
systemctl --user restart openclaw-gateway.service
# 3. 验证生效
openclaw status --json
完整服务操作速查
# === CLIProxyAPI ===
# 启动
systemctl --user start cliproxyapi
# 状态
systemctl --user status cliproxyapi --no-pager
# 重启
systemctl --user restart cliproxyapi
# 日志
journalctl --user -u cliproxyapi -f
# === OpenClaw Gateway ===
# 启动
systemctl --user start openclaw-gateway.service
# 状态
systemctl --user status openclaw-gateway.service --no-pager
# 重启(改配置后必做)
systemctl --user restart openclaw-gateway.service
# 验证
openclaw status --json