In my setup, I am running node js, behind haproxy, using haproxy as a reverse proxy and load balancer, which will route the calls, to the multiple node servers I have running. On each node server I am running multiple independent node processes as below:
PORT=3000 forever start app1/app.js
PORT=3001 forever start app2/app.js
PORT=3002 forever start app3/app.js
etc....
Right now, on each server I am installing multiple instances of my app and starting these processes manually using forever. My question is, how do I automate the starting of these processes, given that they can vary on each server, because I will run (numOfCpus -1 ) processes on each server ?
Also, if I want to run say 10 nodejs processes of the same app on server 1, would I need to install the app in 10 separate folders, or can I just install it in one folder, since its the same code, and somehow have 10 separate instances of it run ?
I am shocked that this is such a fundamental way of running node in production, if you do not want to use cluster mode, yet there is no documentation or material on how to achieve this.