Is there a good way to run and manage multiple nodejs apps on a single server?
I\'ve been looking at haibu and nodester, but they seem a little complex for what I am try
I use Supervisord & Monit, more details and configuration example here: Process Management at Bringr.
Moreover you can specify environnement variable directly from the supervisord configuration file (see sub-process environment). But I personally prefer to add these variables directly inside a ~/.bashrc on each machine.
If the port number isn't going to change for each application (but change between production & development environment). I'll recommend to specify them inside a config.json (or directly inside package.json). And the config.json will contain a different port number for each application depending on the environnement:
{
myapp:{
production:{port:8080},
development:{port:3000}
}
}
And inside myapp.js
:
var config = require('./config');
app.listen(config.myapp[process.env.NODE_ENV].port)
With process.env.NODE_ENV
declared in ~/.bashrc.