You must use environment variables.
In your code, you check this env var:
if(process.env.WITH_SCHEDULE) { ... }
When you start your instances, you set WITH_SCHEDULE for only one instance.
Example pm2.json:
{ "apps": [ { "name": "Example", "script": "boot/app/app.js", "args": [], "error_file": "/srv/www.example.com/logs/error.log", "out_file": "/srv/www.example.com/logs/info.log", "ignore_watch": [ "node_modules" ], "watch": false, "cwd": "/srv/www.example.com/server", "env": { "NODE_ENV": "production", "WITH_SCHEDULE": "1", "HOST": "127.0.0.1", "PORT": "9030" } }, { "name": "Example", "script": "boot/app/app.js", "args": [], "error_file": "/srv/www.example.com/logs/error.log", "out_file": "/srv/www.example.com/logs/info.log", "ignore_watch": [ "node_modules" ], "watch": false, "cwd": "/srv/www.example.com/server", "env": { "NODE_ENV": "production", "HOST": "127.0.0.1", "PORT": "9030" } } ] }
source share