C
C
Caretaker2018-08-08 12:41:53
JSON
Caretaker, 2018-08-08 12:41:53

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

Accordingly, the connection of this config to pm2 is performed by the command: >
pm2 start srv -
pm2.json make changes to JSON > pm2 start srv-pm2.json > pm2 save It turns out not only that the replacement of task identifiers in pm2, but also a short-term shutdown of services. So the question is the following. IS IT POSSIBLE? somehow reread JSON for pm2 so that it automatically removes from its tasks what is removed from the "config" and starts what was added without stopping everything else? Well something like: > pm2 reload srv-pm2.json

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex McArrow, 2018-08-08
@zuart

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 question

Ask a Question

731 491 924 answers to any question