Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda