Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open multiple node.js servers with batch file

I'm using Windows. Currently every time I restart my server I have to run a bunch of commands to get my servers up and running and I'd like to consolidate them into a single batch script if possible.

Here's the process I currently have to run through:

open command prompt
cd /mongodb/bin
mongod

open another command prompt
cd /forum
node proxy.js

open another command prompt
cd /forum
node app.js

open ANOTHER command prompt
cd /game
node app.js

I feel like there is definitely a better way to do this but I can't seem to find an appropriate solution.

like image 365
v3xx3d Avatar asked May 10 '14 20:05

v3xx3d


1 Answers

If you place a batch file in the directory where all these folders are (I guess its your nodejs directory), you can create a start.bat file containing the commands:

start mongodb/bin/mongod
start node forum/proxy.js
start node forum/app.js
start node game/app.js

This will execute every command simultaneously, in a separate window. Save this as a file with a .bat extension and you are done

Old answer:

mongodb/bin/mongod
node forum/proxy.js
node forum/app.js
node game/app.js

Or if you want all the processes to run in a separate window:

start cmd /k mongodb/bin/mongod
start cmd /k node forum/proxy.js
start cmd /k node forum/app.js
start cmd /k node game/app.js

like image 128
MarijnS95 Avatar answered Oct 24 '22 07:10

MarijnS95