@wu529778790/open-im 0.3.9 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +23 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -192,8 +192,29 @@ else if (args[0] === 'restart') {
192
192
  await stopService().catch((err) => {
193
193
  console.error('停止服务时出错:', err);
194
194
  });
195
- // 等待进程完全退出
196
- await new Promise(resolve => setTimeout(resolve, 1000));
195
+ // 等待进程完全退出 AND Telegram API 释放连接(至少 3 秒)
196
+ // Telegram 需要时间释放 bot 实例,否则会出现 409 Conflict 错误
197
+ const pid = await readPid();
198
+ if (pid) {
199
+ // 持续检查直到进程真正退出(最多 15 秒)
200
+ const maxWait = 15000;
201
+ const checkInterval = 500;
202
+ let waited = 0;
203
+ while (waited < maxWait) {
204
+ if (!(await isProcessRunning(pid))) {
205
+ // 进程已退出,再等待 3 秒让 Telegram API 完全释放
206
+ const remainingWait = 3000;
207
+ console.log(`进程已退出,等待 ${remainingWait / 1000} 秒让 Telegram API 释放连接...`);
208
+ await new Promise(resolve => setTimeout(resolve, remainingWait));
209
+ break;
210
+ }
211
+ await new Promise(resolve => setTimeout(resolve, checkInterval));
212
+ waited += checkInterval;
213
+ }
214
+ if (waited >= maxWait) {
215
+ console.log('警告: 进程退出超时,继续启动...');
216
+ }
217
+ }
197
218
  console.log('\n正在重新启动服务...\n');
198
219
  await startService();
199
220
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "description": "Multi-platform IM bridge for AI CLI tools (Claude, Codex, Cursor)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",