keymetrics / pm2-plus-tech-questions

http://docs.keymetrics.io/docs/pages/faq-troubleshooting/
27 stars 3 forks source link

How to pass in node args during post deploy? #298

Open jtoronto opened 2 years ago

jtoronto commented 2 years ago

I'm using an ecosyste.config.js file. I need to pass in an argument when starting my app but only during post deploy startup.

I know I can use

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

but that passes the args on every startup.

I also tried putting the args behind -- in the post deploy string but they're not showing up in process.argv.

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"
    }
  }

How can this be accomplished?