warn instead of crashing when an app fails to load

This commit is contained in:
AJ ONeal 2015-02-15 21:45:41 +00:00
parent e4a13a8b80
commit 233c6cd8ef
1 changed files with 9 additions and 1 deletions

View File

@ -68,7 +68,15 @@ require('ssl-root-cas')
function getAppContext(domaininfo) {
var localApp;
localApp = require(path.join(__dirname, 'vhosts', domaininfo.dirname, 'app.js'));
try {
localApp = require(path.join(__dirname, 'vhosts', domaininfo.dirname, 'app.js'));
} catch(e) {
console.error("[ERROR] could not load app.js for " + domaininfo.dirname);
console.error(e);
return PromiseA.resolve(connect().use('/', function (req, res) {
res.end('{ "error": { "message": "could not load app.js for ' + domaininfo.dirname + '" } }');
}));
}
if (localApp.create) {
// TODO read local config.yml and pass it in
// TODO pass in websocket