Running two node servers from a single shell command using a shell script Running two node servers from a single shell command using a shell script unix unix

Running two node servers from a single shell command using a shell script


Your command does not work because you are trying to have two processes running in the same shell. Instead, you should 'spawn' the node processes into different processes. Try this command:

node project/rest.js & node static-server.js &


i have written very simple shell script, for starting MongoDB, start multiple node servers in a new terminal window and open Webstorm Ide.

it uses https://github.com/mklement0/ttab library, for opening new terminal windows.

you can specify multiple projects in code and with simple if elseor maybe with switch statement, differentiate projects.

sh dev.sh waufwauf   

will cd and start waufwauf project, hope it helps.

#!/bin/bashif [ "$1" = "waufwauf" ]then  cd Code/waufwauf;    ttab -d ./ mongod;    ttab -d server npm run dev;    ttab -d client npm run dev;    wstorm ~/Code/waufwauf;elif [ "$1" = "" ]then    echo specify project name;  else    echo $1 unknown project;fi


try this, this will work,

start node project/rest.js && start node static-server.js