Make PM2 worker memory restart opt-in

This commit is contained in:
Ben
2026-06-22 10:06:00 -04:00
parent 126b05224f
commit da85871165
2 changed files with 10 additions and 2 deletions
+3 -1
View File
@@ -31,7 +31,9 @@ STRATUM_PORTS=3333,3332,3331,3330
# Optional PPLNS-mode SV1/SV2 autodetect ports. # Optional PPLNS-mode SV1/SV2 autodetect ports.
#PPLNS_STRATUM_PORTS= #PPLNS_STRATUM_PORTS=
STRATUM_WORKERS=2 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_MIN_DIFFICULTY=1
STRATUM_SOCKET_TIMEOUT_MS=3600000 STRATUM_SOCKET_TIMEOUT_MS=3600000
STRATUM_TCP_KEEPALIVE_INITIAL_DELAY_MS=60000 STRATUM_TCP_KEEPALIVE_INITIAL_DELAY_MS=60000
+7 -1
View File
@@ -4,6 +4,12 @@ const dockerLogConfig = {
merge_logs: true, 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 = { module.exports = {
apps: [ apps: [
// API instance // API instance
@@ -42,7 +48,7 @@ module.exports = {
script: './dist/main.js', script: './dist/main.js',
instances: parseInt(process.env.STRATUM_WORKERS || '2', 10), instances: parseInt(process.env.STRATUM_WORKERS || '2', 10),
exec_mode: "cluster", exec_mode: "cluster",
max_memory_restart: process.env.STRATUM_WORKER_MAX_MEMORY_RESTART || '4096M', ...stratumWorkerMemoryRestart,
env: { env: {
MASTER: 'false', MASTER: 'false',
API_ENABLED: 'false', API_ENABLED: 'false',