Last active
January 27, 2022 15:32
-
-
Save devicezero/eb98c1ea802e2e12ef92bcf420e2cf01 to your computer and use it in GitHub Desktop.
ecosystem.config.js example for psh number of cpus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
let numberOfProcesses = 1; | |
let maxMemory = 64; | |
// use number of cpus from config.json on grid | |
if (fs.existsSync("/run/config.json")) { | |
const pshConfig = require("/run/config.json"); | |
numberOfProcesses = Math.ceil(pshConfig.info.limits.cpu); | |
maxMemory = pshConfig.info.limits.memory; | |
} | |
// untested territory | |
// use number of cpus from Node.js OS utility on dedicated generation 2 | |
// if (process.env.PLATFORM_MODE === "enterprise") { | |
// const os = require("os"); | |
// // how much of the cpu/memory consumption depends on what else is running | |
// numberOfProcesses = os.cpus().length; | |
// // this is using 1/3 of the max memory of the machine, adjust as necessary | |
// maxMemory = Math.ceil((os.totalmem() / 1024 / 1000) * 0.33); | |
// } | |
module.exports = { | |
apps: [ | |
{ | |
script: "index.js", | |
instances: numberOfProcesses, | |
exec_mode: "cluster", | |
max_memory_restart: `${maxMemory}M`, | |
node_args: `--max_old_space_size=${maxMemory}`, | |
env: { | |
NODE_ENV: "production", | |
}, | |
}, | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
update comments from
#
to//