Answer the question
In order to leave comments, you need to log in
How to reread PM2 processes json file without recreating?
Greetings.
There is a service process written in NodeJS. In fact, it is the same, just several copies are launched with different input configs. In order to make it convenient to manage both visually and technically a group of settings, this kind is connected to pm2 using a JSON file [ srv-pm2.json ] of the following form:
{
"apps": [
{
"exec_mode": "fork_mode",
"script": "service.js",
"name": "service.1",
"args": "--config config1.json",
"env": { "NODE_ENV": "production" },
"max_memory_restart": "150M"
},
{
"exec_mode": "fork_mode",
"script": "service.js",
"name": "service.2",
"args": "--config config2.json",
"env": { "NODE_ENV": "production" },
"max_memory_restart": "150M"
},
{
"exec_mode": "fork_mode",
"script": "service.js",
"name": "service.3",
"args": "--config config3.json",
"env": { "NODE_ENV": "production" },
"max_memory_restart": "150M"
}
]
}
Answer the question
In order to leave comments, you need to log in
Sorry for being direct.
And what prevents you from breaking this file into 3 blocks and starting those that you need, stopping or reloading those that you need, adding or deleting - what you need.
Yes, you will have to call pm2 many times to start each server - but you will get the flexibility you need.
Well, or read the documentation: ( pm2.keymetrics.io/docs/usage/application-declarati...
Act on a specific process
You can also act on a particular application by using its name and the option --only :
pm2 start ecosystem. config.js --only api-app
pm2 restart ecosystem.config.js --only api-app
pm2 reload ecosystem.config.js --only api-app
pm2 delete ecosystem.config.js --only api-app
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question