From c72b3155c26f78f797b846f5d398b66d8ea2409b Mon Sep 17 00:00:00 2001 From: zhangzikuan Date: Sun, 1 Feb 2026 21:32:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20stop=20=E5=91=BD=E4=BB=A4=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E8=AF=A6=E7=BB=86=E7=9A=84=E5=85=B3=E9=97=AD=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化 stop 命令的日志输出,现在会显示每个服务器的关闭过程: - Closing connection to alibaba-cloud-observability... - Closing connection to alibaba-dms... - ... 与 restart 命令的日志风格保持一致。 Co-Authored-By: Claude Sonnet 4.5 --- src/commands/daemon.ts | 62 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/src/commands/daemon.ts b/src/commands/daemon.ts index 345d5b2..32d6ce3 100644 --- a/src/commands/daemon.ts +++ b/src/commands/daemon.ts @@ -203,8 +203,66 @@ const startAction = async (options: any) => { const stopAction = async (options?: any) => { try { - await daemonRequest('POST', '/stop'); - console.log(chalk.green('Daemon stopped successfully.')); + const logPath = '/tmp/mcps-daemon/stdout.log'; + const fs = await import('fs'); + + // 发送 stop 请求并显示日志 + const requestPromise = daemonRequest('POST', '/stop'); + + // 显示关闭日志 + const showLogs = async () => { + try { + if (!fs.existsSync(logPath)) { + return; + } + + let lastSize = fs.statSync(logPath).size; + const startTime = Date.now(); + const timeout = 5000; // 5秒超时 + + while (Date.now() - startTime < timeout) { + await new Promise(r => setTimeout(r, 200)); + + try { + const { size: currentSize } = fs.statSync(logPath); + if (currentSize > lastSize) { + const buffer = Buffer.alloc(currentSize - lastSize); + const fd = fs.openSync(logPath, 'r'); + fs.readSync(fd, buffer, 0, currentSize - lastSize, lastSize); + fs.closeSync(fd); + + const newLogs = buffer.toString('utf-8'); + const relevantLogs = newLogs.split('\n').filter(line => { + return line.includes('Closing connection to') || + line.includes('Shutting down'); + }); + + if (relevantLogs.length > 0) { + relevantLogs.forEach(log => { + if (log.trim()) { + console.log(chalk.yellow(log)); + } + }); + lastSize = currentSize; + } + } + } catch (e) { + // 忽略读取错误 + } + } + } catch (e) { + // 忽略日志显示错误 + } + }; + + const [{ ok }] = await Promise.all([ + requestPromise, + showLogs() + ]); + + if (ok) { + console.log(chalk.green('Daemon stopped successfully.')); + } } catch (e) { console.error(chalk.red('Failed to stop daemon. Is it running?')); } From ab53fdb1c824c285ab312ab1cc6561a31094948b Mon Sep 17 00:00:00 2001 From: zhangzikuan Date: Sun, 1 Feb 2026 21:32:56 +0800 Subject: [PATCH 2/2] 1.1.5 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0557ff5..f271f49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@maplezzk/mcps", - "version": "1.1.4", + "version": "1.1.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@maplezzk/mcps", - "version": "1.1.4", + "version": "1.1.5", "license": "ISC", "dependencies": { "@modelcontextprotocol/sdk": "^1.25.3", diff --git a/package.json b/package.json index 737b74e..82305b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maplezzk/mcps", - "version": "1.1.4", + "version": "1.1.5", "description": "A CLI to manage and use MCP servers", "publishConfig": { "access": "public"