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',