1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Handle port-in-use error on start-up

This commit is contained in:
Nick O'Leary 2014-04-21 21:42:59 +01:00
parent c20128b80f
commit c39f4f9738

15
red.js
View File

@ -163,6 +163,16 @@ function getListenPath() {
RED.start().then(function() { RED.start().then(function() {
if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) { if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) {
server.on('error', function(err) {
if (err.errno === "EADDRINUSE") {
util.log('[red] Unable to listen on '+getListenPath());
util.log('[red] Error: port in use');
} else {
util.log('[red] Uncaught Exception:');
util.log(err.stack);
}
process.exit(1);
});
server.listen(settings.uiPort,settings.uiHost,function() { server.listen(settings.uiPort,settings.uiHost,function() {
if (settings.httpAdminRoot === false) { if (settings.httpAdminRoot === false) {
util.log('[red] Admin UI disabled'); util.log('[red] Admin UI disabled');
@ -176,13 +186,8 @@ RED.start().then(function() {
process.on('uncaughtException',function(err) { process.on('uncaughtException',function(err) {
if (err.errno === "EADDRINUSE") {
util.log('[red] Unable to listen on '+getListenPath());
util.log('[red] Error: port in use');
} else {
util.log('[red] Uncaught Exception:'); util.log('[red] Uncaught Exception:');
util.log(err.stack); util.log(err.stack);
}
process.exit(1); process.exit(1);
}); });