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?
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.
I will answer this in two parts.
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.
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.