pm2-plus-tech-questions icon indicating copy to clipboard operation
pm2-plus-tech-questions copied to clipboard

How to pass in node args during post deploy?

Open jtoronto opened this issue 2 years ago • 0 comments

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" : "[email protected]: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?

jtoronto avatar Jun 09 '22 18:06 jtoronto