1

I'm developing a large scale system (MEAN Stack + ElasticSearch + RabbitMQ), There are many different nodejs projects and queues working together. I a few questions.

  1. When I want run and test the whole system, I have to open a lot of terminal windows to run each project. How do I run them at once with ease of monitoring.

  2. When I want to run the same project on multiple machine, How can I easily config all of them because sometime it takes too much time to move around and config them one bye one.

  3. How to config, run, monitor and manage the whole system easily. For example, I want to know how many machine is running a project. Or sometime I want to change message queue name or ip address at once, I don't want to go to every machine on both project to change them one bye one

Sorry for my bad gramma, Feel free the edit. Thanks in advance.

Methuz Kaewsai-kao
  • 1,176
  • 2
  • 10
  • 22
  • Big meta questions like this usually get closed quickly here (with a few notable exceptions). If you want to have a more successful question, I would recommend only asking a single question at a time and trying to be as specific as you can about what you're asking. – Wesley Bland Jan 16 '15 at 20:01

2 Answers2

2

Have a look at PM2.
I'm using it for developement and in production

With this tool you can define a simple JSON file that defines your environment.

pm2_services.json

[{
  "name"        : "WORKER",
  "script"      : "worker.js",
  "instances"   : "3",
  "port"        : 3002,
  "node-args"   : "A_CONFIG_KEY"
}, {
  "name"        : "BACKEND",
  "script"      : "backend.js",
  "instances"   : "3",
  "port"        : 3000,
  "node-args"   : "A_CONFIG_KEY"
}, {
  "name"        : "FRONTEND",
  "script"      : "frontend.js",
  "instances"   : "3",
  "port"        : 3001,
  "node-args"   : "A_CONFIG_KEY"
}]

Then run pm2 start pm2_services.json

Relevant commands:

  • pm2 logs show the logs of all services
  • pm2 ls show the running
  • pm2 monit show the current cpu and memory state
  • pm2 start FRONTEND to start a service
  • pm2 stop FRONTEND to stop a service

NOTE:

Be careful with the watch feature of PM2.
In my case my CPU jumps up to permanent 100%.

To watch many file for change i use node-dev.
And here's the solution ti use it with PM2

[{
  "name"        : "WORKER",
  "script"      : "worker.js",
  "instances"   : 1,
  "watch"       : false,
  "exec_interpreter" : "node-dev",
  "exec_mode"   : "fork_mode"
}]
mpneuried
  • 181
  • 3
0
  1. You could write a Node project which launches all the other ones with appropriate arguments using child_process.
  2. You could consider a tool like Puppet or Chef.
  3. Same as #2.
John Zwinck
  • 239,568
  • 38
  • 324
  • 436