Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!