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.