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

146
Visualizações
PM2 node args but only post during/post deploy?

I'm using PM2 for deployment using ecosystem file, and while I know I can pass in node args like this;

{
  "apps": [
    {
      "name": "myApp",
      "script": "./myApp.js",
      "args": "--randomArgs"
    }
  ]
}

This uses those arguments on every startup. I want to only using this argument when deploying or more specifically as part of the post-deploy routine. My code has some post-deploy things it needs to do on first startup indicated by this CLI argument, but not on any subsequent starts.

I've tried doing it this way.

deploy : {
    development : {
       "user" : "ubuntu",
       "host" : ["192.168.0.13", "192.168.0.14", "192.168.0.15"],
       "ref"  : "origin/master",
       "repo" : "git@github.com:Username/repository.git",
       "path" : "/var/www/my-repository",
       "post-deploy" : "npm install && pm2 startOrRestart ecosystem.config.js --randomArgs --update-env --env development"
    }
  }

But the args aren't visible in process.argv. I also tried --node-args="--randomArgs" in the post-deploy CLI string and that didn't work either.

It only works if I put it in the apps section of ecosystem.config.js but that's not the desired action.

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