Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have to run two node servers in different port, I want to write a simple shell script that will start both of the servers.

I wrote it like below:

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

but when I run the commands at a time, it starts the first server and dont execute the second one.

And only the fist server listens for request, second static server doesn't start. And in the shell I do have a output from rest.js.

What I previously did to run tow servers, I run two commands in different shell.

Is there a way I can run both of the server with a single shell script?

Thanks in advance.

share|improve this question

1 Answer

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 &
share

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.