My Node.Js Docker app runs on pm2 and uses the following config:
module.exports = [
{
script: 'dist/src/main.js',
name: 'infrasonic',
exec_mode: 'fork_mode',
autorestart: true,
env: {
NODE_ENV: 'production',
},
env_development: {
NODE_ENV: 'development',
},
watch: process.env.NODE_ENV == 'development' ? true : false,
watch_delay: 60000,
ignore_watch: ['node_modules'],
max_memory_restart: '1G',
},
];
in this setup if my app is unresponsive for about a minute, PM2 restarts the app.
I don't want this behavior, so I want it to wait at least 2 minutes of unresponsiveness before it restarts the app.
I rewrote the ecosystem.config.js file in the following way:
module.exports = [
{
script: 'dist/src/main.js',
name: 'infrasonic',
exec_mode: 'cluster',
instances: 1,
autorestart: true,
env: {
NODE_ENV: 'production',
},
env_development: {
NODE_ENV: 'development',
},
watch: process.env.NODE_ENV == 'development' ? true : false,
watch_delay: 60000,
ignore_watch: ['node_modules'],
max_memory_restart: '1G',
},
];
switching it into cluster mode as I read it has 0 downtime.
Do you think there's another solution where I can specify the duration of unresponsiveness (120 seconds) directly after which PM2 restarts?