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

Unexpected error if uiPort already in use

This commit is contained in:
Nick O'Leary 2014-03-17 15:58:44 +00:00
parent d87cc471a0
commit 15d642c55d

25
red.js
View File

@ -149,22 +149,25 @@ if (settings.httpStatic) {
app.use("/",express.static(settings.httpStatic)); app.use("/",express.static(settings.httpStatic));
} }
function getListenPath() {
var listenPath = 'http'+(settings.https?'s':'')+'://'+
(settings.uiHost == '0.0.0.0'?'127.0.0.1':settings.uiHost)+
':'+settings.uiPort;
if (settings.httpAdminRoot !== false) {
listenPath += settings.httpAdminRoot;
} else if (settings.httpStatic) {
listenPath += "/";
}
return listenPath;
}
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) {
var listenPath = 'http'+(settings.https?'s':'')+'://'+
(settings.uiHost == '0.0.0.0'?'127.0.0.1':settings.uiHost)+
':'+settings.uiPort;
if (settings.httpAdminRoot !== false) {
listenPath += settings.httpAdminRoot;
} else if (settings.httpStatic) {
listenPath += "/";
}
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');
} }
util.log('[red] Server now running at '+listenPath); util.log('[red] Server now running at '+getListenPath());
}); });
} else { } else {
util.log('[red] Running in headless mode'); util.log('[red] Running in headless mode');
@ -174,7 +177,7 @@ RED.start().then(function() {
process.on('uncaughtException',function(err) { process.on('uncaughtException',function(err) {
if (err.errno === "EADDRINUSE") { if (err.errno === "EADDRINUSE") {
util.log('[red] Unable to listen on '+listenPath); util.log('[red] Unable to listen on '+getListenPath());
util.log('[red] Error: port in use'); util.log('[red] Error: port in use');
} else { } else {
util.log('[red] Uncaught Exception:'); util.log('[red] Uncaught Exception:');