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

145
Vistas
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 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