PM2 Gateway Restart
This skill provides reliable gateway restart using PM2 process manager instead of the built-in openclaw gateway commands.
Why PM2?
The standard openclaw gateway start/stop commands on Windows suffer from:
- - FINWAIT2 TCP connection timeouts (~60 seconds)
- Scheduled task race conditions
- Inconsistent startup state reporting
PM2 handles process resurrection and provides reliable restarts.
Commands
Quick Restart (Production)
pm2 restart openclaw-gateway
Wait ~15 seconds for the gateway to fully initialize, then verify with:
CODEBLOCK1
Full Cycle Restart (When Issues Persist)
CODEBLOCK2
Check Status
CODEBLOCK3
Start Gateway (If Not Running)
CODEBLOCK4
Troubleshooting
Port Still in Use After Restart
Wait 65 seconds for Windows TCP timeout to clear FIN
WAIT2 connections, then:
CODEBLOCK5
RPC Probe Fails But Gateway Listening
The RPC check may fail briefly during startup. Wait 15 seconds and retry:
CODEBLOCK6
PM2 Process Not Found
Reinstall the gateway process:
CODEBLOCK7
Setup (One Time)
CODEBLOCK8
PM2 网关重启
本技能提供使用PM2进程管理器替代内置openclaw网关命令的可靠网关重启方案。
为何选择PM2?
Windows系统上标准的openclaw gateway start/stop命令存在以下问题:
- - FINWAIT2 TCP连接超时(约60秒)
- 计划任务竞态条件
- 启动状态报告不一致
PM2可处理进程复活并提供可靠的重启功能。
命令
快速重启(生产环境)
powershell
pm2 restart openclaw-gateway
等待约15秒让网关完全初始化,然后使用以下命令验证:
powershell
curl http://127.0.0.1:18789/
完整周期重启(问题持续时)
powershell
pm2 restart openclaw-gateway; sleep 3; pm2 restart openclaw-gateway
检查状态
powershell
pm2 status
pm2 logs openclaw-gateway --lines 50
启动网关(如未运行)
powershell
pm2 start D:/Program Files/nodejs/node.exe --name openclaw-gateway -- C:/Users/Administrator/AppData/Roaming/npm/node_modules/openclaw/dist/index.js gateway --port 18789
故障排除
重启后端口仍被占用
等待65秒让Windows TCP超时清除FIN
WAIT2连接,然后:
powershell
pm2 restart openclaw-gateway
RPC探测失败但网关正在监听
启动期间RPC检查可能短暂失败。等待15秒后重试:
powershell
curl http://127.0.0.1:18789/
未找到PM2进程
重新安装网关进程:
powershell
pm2 start D:/Program Files/nodejs/node.exe --name openclaw-gateway -- C:/Users/Administrator/AppData/Roaming/npm/node_modules/openclaw/dist/index.js gateway --port 18789
pm2 save
安装配置(一次性)
powershell
npm install -g pm2
pm2 start D:/Program Files/nodejs/node.exe --name openclaw-gateway -- C:/Users/Administrator/AppData/Roaming/npm/node_modules/openclaw/dist/index.js gateway --port 18789
pm2 save