diff --git a/config/default.json b/config/default.json index 9329147..4f2e816 100644 --- a/config/default.json +++ b/config/default.json @@ -19,6 +19,7 @@ "consoleStatus": false }, "monitor": { + "enabled": true, "reboot": false, "minMemory": 30000, "maxMemStartMultiple": 2, diff --git a/config/local.json.example b/config/local.json.example index 9e7235c..9947082 100644 --- a/config/local.json.example +++ b/config/local.json.example @@ -12,6 +12,8 @@ "host": "127.0.0.1" }, "monitor":{ + "enabled": true, + // when enabled reboot instead restart "reboot": false, // min required memory "minMemory": 30000, diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index 70622c0..28f5156 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -21,6 +21,7 @@ interface Config { consoleStatus: boolean; }; monitor: { + enabled: boolean; reboot: boolean; minMemory: number; maxMemStartMultiple: number; diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 70ef5de..9569fa9 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -82,7 +82,7 @@ wssDevice.on('connection', (ws, req) => { const memoryStatus = await device.getMemoryUsage(); log.info(`${device.deviceId}/${device.instanceNo}:Memory = ${JSON.stringify(memoryStatus)}`); let restartRequired = false; - if (memoryStatus.memFree && memoryStatus.memFree < config.monitor.minMemory) { + if (config.monitor.enabled && memoryStatus.memFree && memoryStatus.memFree < config.monitor.minMemory) { log.warn( `${device.deviceId}/${device.instanceNo}: ${memoryStatus.memFree} < ${config.monitor.minMemory} - RESTART REQUIRED`, ); @@ -97,7 +97,7 @@ wssDevice.on('connection', (ws, req) => { ? config.monitor.maxMemStartMultipleOverwrite[prefix] : config.monitor.maxMemStartMultiple; - if (memoryStatus.memMitm > memoryStatus.memStart * value) { + if (config.monitor.enabled && memoryStatus.memMitm > memoryStatus.memStart * value) { log.warn( `${device.deviceId}/${device.instanceNo}: ${memoryStatus.memMitm} > ${memoryStatus.memStart} * ${value} - RESTART REQUIRED`, );