mcp-log-query-server 3.5.0 → 3.5.1

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.
package/config.js CHANGED
@@ -81,6 +81,15 @@ export const SERVICES = {
81
81
  logFile: 'normal.log',
82
82
  aliases: ['core', '核心']
83
83
  },
84
+ 'clife-senior-crm': {
85
+ name: 'clife-senior-crm',
86
+ description: '养老CRM客户关系管理服务',
87
+ namespace: 'saas-itest',
88
+ podPattern: 'clife-senior-crm-app',
89
+ logPath: '/www/logs/clife-senior-crm-app/normal_logs',
90
+ logFile: 'normal.log',
91
+ aliases: ['crm', '客户关系', '客户管理']
92
+ },
84
93
  'clife-senior-device-scene-base': {
85
94
  name: 'clife-senior-device-scene-base',
86
95
  description: '养老设备场景基础服务',
package/index.js CHANGED
@@ -56,7 +56,7 @@ process.on('uncaughtException', (err) => console.error('[uncaughtException]', er
56
56
  const server = new Server(
57
57
  {
58
58
  name: 'mcp-log-query',
59
- version: '3.5.0',
59
+ version: '3.5.1',
60
60
  },
61
61
  {
62
62
  capabilities: {
@@ -844,7 +844,7 @@ async function main() {
844
844
 
845
845
  const transport = new StdioServerTransport();
846
846
  await server.connect(transport);
847
- console.error('[MCP] Log Query Server v3.5.0 已启动 (超时保护 + SSH 并发限制 + 进程不自杀 + stdin 优雅关闭)');
847
+ console.error('[MCP] Log Query Server v3.5.1 已启动 (超时保护 + SSH 并发限制 + 排队超时 + 进程不自杀 + stdin 优雅关闭)');
848
848
  }
849
849
 
850
850
  main().catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-log-query-server",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "MCP Server for querying server logs via SSH jump host and Grafana Loki API",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/ssh-client.js CHANGED
@@ -21,6 +21,8 @@ import { JUMP_HOST, K8S_SERVER, DEFAULTS } from './config.js';
21
21
  // ============================================================
22
22
  const SSH_MAX_CONCURRENT = parseInt(process.env.SSH_MAX_CONCURRENT || '3', 10);
23
23
  const SSH_QUEUE_MAX = parseInt(process.env.SSH_QUEUE_MAX || '50', 10);
24
+ // 排队等待最长时间(毫秒),防止前面请求卡死后面无限等
25
+ const SSH_ACQUIRE_TIMEOUT = parseInt(process.env.SSH_ACQUIRE_TIMEOUT || '60000', 10);
24
26
 
25
27
  const _sshSem = {
26
28
  active: 0,
@@ -29,26 +31,50 @@ const _sshSem = {
29
31
  queueMax: SSH_QUEUE_MAX,
30
32
  };
31
33
 
32
- function sshAcquire() {
34
+ /**
35
+ * 获取 SSH 信号量槽位
36
+ * @param {number} [timeoutMs] - 排队超时(默认 60s),防止无限等
37
+ * @returns {Promise<void>}
38
+ */
39
+ function sshAcquire(timeoutMs = SSH_ACQUIRE_TIMEOUT) {
33
40
  if (_sshSem.active < _sshSem.max) {
34
41
  _sshSem.active++;
42
+ console.error(`[SSH-Sem] acquire 直接通过 (active=${_sshSem.active}/${_sshSem.max}, queue=${_sshSem.queue.length})`);
35
43
  return Promise.resolve();
36
44
  }
37
45
  if (_sshSem.queue.length >= _sshSem.queueMax) {
38
46
  return Promise.reject(new Error(`SSH 并发队列已满(>${_sshSem.queueMax}),请稍后重试`));
39
47
  }
40
- return new Promise(resolve => {
41
- _sshSem.queue.push(() => {
48
+ console.error(`[SSH-Sem] acquire 进入排队 (active=${_sshSem.active}/${_sshSem.max}, queue=${_sshSem.queue.length + 1}, timeout=${timeoutMs}ms)`);
49
+ return new Promise((resolve, reject) => {
50
+ let settled = false;
51
+ const enterQueue = () => {
52
+ if (settled) return; // 已超时,放弃并立刻腾位给下一个
53
+ settled = true;
54
+ clearTimeout(timer);
42
55
  _sshSem.active++;
56
+ console.error(`[SSH-Sem] acquire 出队获得槽位 (active=${_sshSem.active}/${_sshSem.max}, queue=${_sshSem.queue.length})`);
43
57
  resolve();
44
- });
58
+ };
59
+ _sshSem.queue.push(enterQueue);
60
+ const timer = setTimeout(() => {
61
+ if (settled) return;
62
+ settled = true;
63
+ // 从队列里移除自己的 entry
64
+ const idx = _sshSem.queue.indexOf(enterQueue);
65
+ if (idx >= 0) _sshSem.queue.splice(idx, 1);
66
+ console.error(`[SSH-Sem] acquire 排队超时 (${timeoutMs}ms, active=${_sshSem.active}/${_sshSem.max}, queue=${_sshSem.queue.length})`);
67
+ reject(new Error(`SSH 排队等待超时 (${timeoutMs}ms):前面请求卡住,或并发过高。可调整 SSH_MAX_CONCURRENT / SSH_ACQUIRE_TIMEOUT`));
68
+ }, timeoutMs);
45
69
  });
46
70
  }
47
71
 
48
72
  function sshRelease() {
49
73
  _sshSem.active = Math.max(0, _sshSem.active - 1);
74
+ // 超时的 entry 已在 timer 里从 queue 移除,这里 shift 到的都是活的
50
75
  const next = _sshSem.queue.shift();
51
76
  if (next) next();
77
+ console.error(`[SSH-Sem] release (active=${_sshSem.active}/${_sshSem.max}, queue=${_sshSem.queue.length})`);
52
78
  }
53
79
 
54
80
  /**