Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
How to prevent PM2 autorestart after the app is unresponsive for some period of time?

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?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda