1

I have to run three separate app in node js listening port 80.Now i am using this method

app.get('/barcelona/*', function(request, response) {

});
app.get('/real_madrid/*', function(request, response) {

});
app.get('/manchester/*', function(request, response) {

});

When i change something in "barcelona" or "real_madrid" or "manchester" ,I have to restart all my application.If any syntax error , the whole app will down. I want something like php.the error in apps will not affect each other.How can i do this?

1
  • 1
    if these apps are completely independent, it's much better to create three separate servers and use a reverse proxy. Commented Feb 4, 2013 at 4:33

2 Answers 2

2

A common way to do this is to put a proxy in front, such as nginx. The proxy can route requests to specific Node.js-based applications transparently.

Sign up to request clarification or add additional context in comments.

Comments

1

I will answer this in two parts.

  1. Handling exceptions. In Node.js, if an exception occurs in the execution of your application, the whole application will be brought down. The main reason of the same is the single threaded nature of JavaScript. Its always better to handle the exceptions in the application rather than leaving to the runtime.

  2. Re-deployment after changes / bug-fixes. I use Naught.js for managing my deployment in production. Naught.js will monitor your node process and it will restart the process if your application goes down. After code changes, you can use Naught.js to deploy the changes. Naught.js will shutdown the old process only after bringing up a new process with the latest changes. This will ensure zero downtime of your application. Forver also does something similar.

If you are looking for running multiple instances of your application, you can try this out.

1 Comment

How threading is set up has no bearing on unhandled exceptions. If your application crashes due to an unhandled exception, it wouldn't matter if you had 100 threads. You are confusing threads with processes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.