From da858711651a616ee329fe8aa45b523099f7fdd2 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 22 Jun 2026 10:06:00 -0400 Subject: [PATCH] Make PM2 worker memory restart opt-in --- .env.example | 4 +++- ecosystem.config.js | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index c3b8bd8..0cbf756 100644 --- a/.env.example +++ b/.env.example @@ -31,7 +31,9 @@ STRATUM_PORTS=3333,3332,3331,3330 # Optional PPLNS-mode SV1/SV2 autodetect ports. #PPLNS_STRATUM_PORTS= STRATUM_WORKERS=2 -STRATUM_WORKER_MAX_MEMORY_RESTART=4096M +# Optional PM2 per-worker memory recycle. Leave unset unless you accept PM2 +# restarting workers when this limit is reached. +#STRATUM_WORKER_MAX_MEMORY_RESTART=4096M STRATUM_MIN_DIFFICULTY=1 STRATUM_SOCKET_TIMEOUT_MS=3600000 STRATUM_TCP_KEEPALIVE_INITIAL_DELAY_MS=60000 diff --git a/ecosystem.config.js b/ecosystem.config.js index c4fd413..019f2c5 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -4,6 +4,12 @@ const dockerLogConfig = { merge_logs: true, }; +const stratumWorkerMemoryLimit = process.env.STRATUM_WORKER_MAX_MEMORY_RESTART; +const stratumWorkerMemoryRestart = + stratumWorkerMemoryLimit && !['0', 'false', 'off', 'disabled'].includes(stratumWorkerMemoryLimit.toLowerCase()) + ? { max_memory_restart: stratumWorkerMemoryLimit } + : {}; + module.exports = { apps: [ // API instance @@ -42,7 +48,7 @@ module.exports = { script: './dist/main.js', instances: parseInt(process.env.STRATUM_WORKERS || '2', 10), exec_mode: "cluster", - max_memory_restart: process.env.STRATUM_WORKER_MAX_MEMORY_RESTART || '4096M', + ...stratumWorkerMemoryRestart, env: { MASTER: 'false', API_ENABLED: 'false',