Commit a8084e46 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Fix #373 UI won't start if network configuration has changed

parent 055134a3
...@@ -65,10 +65,12 @@ function WebAdmin (dbConf, overConf) { ...@@ -65,10 +65,12 @@ function WebAdmin (dbConf, overConf) {
yield pluggedDALP; yield pluggedDALP;
let host = server.conf ? [server.conf.ipv4, server.conf.port].join(':') : ''; let host = server.conf ? [server.conf.ipv4, server.conf.port].join(':') : '';
let current = yield server.dal.getCurrentBlockOrNull(); let current = yield server.dal.getCurrentBlockOrNull();
let parameters = yield server.dal.getParameters();
return { return {
"host": host, "host": host,
"current": current, "current": current,
"pubkey": base58.encode(server.pair.publicKey) "pubkey": base58.encode(server.pair.publicKey),
"parameters": parameters
}; };
}); });
...@@ -82,7 +84,13 @@ function WebAdmin (dbConf, overConf) { ...@@ -82,7 +84,13 @@ function WebAdmin (dbConf, overConf) {
this.startHTTP = () => co(function *() { this.startHTTP = () => co(function *() {
yield pluggedDALP; yield pluggedDALP;
return bmapi.openConnections(); try {
yield bmapi.openConnections();
return { success: true };
} catch (e) {
logger.error(e);
return { success: false };
}
}); });
this.openUPnP = () => co(function *() { this.openUPnP = () => co(function *() {
......
...@@ -170,8 +170,6 @@ module.exports = { ...@@ -170,8 +170,6 @@ module.exports = {
let httpServer = httpServers[i].http; let httpServer = httpServers[i].http;
let isListening = listenings[i]; let isListening = listenings[i];
if (!isListening) { if (!isListening) {
listenings[i] = true;
let netInterface = interfaces[i].ip; let netInterface = interfaces[i].ip;
let port = interfaces[i].port; let port = interfaces[i].port;
try { try {
...@@ -183,6 +181,7 @@ module.exports = { ...@@ -183,6 +181,7 @@ module.exports = {
//httpServer.on('listening', resolve.bind(this, httpServer)); //httpServer.on('listening', resolve.bind(this, httpServer));
httpServer.listen(port, netInterface, (err) => { httpServer.listen(port, netInterface, (err) => {
if (err) return reject(err); if (err) return reject(err);
listenings[i] = true;
resolve(httpServer); resolve(httpServer);
}); });
}); });
......
...@@ -410,7 +410,8 @@ dtos.Boolean = { ...@@ -410,7 +410,8 @@ dtos.Boolean = {
dtos.AdminSummary = { dtos.AdminSummary = {
"host": String, "host": String,
"current": dtos.Block, "current": dtos.Block,
"pubkey": String "pubkey": String,
"parameters": dtos.Parameters
}; };
dtos.PreviewPubkey = { dtos.PreviewPubkey = {
......
...@@ -5,7 +5,7 @@ var logger = require('../app/lib/logger')('ucoind'); ...@@ -5,7 +5,7 @@ var logger = require('../app/lib/logger')('ucoind');
process.on('uncaughtException', function (err) { process.on('uncaughtException', function (err) {
// Dunno why this specific exception is not caught // Dunno why this specific exception is not caught
if (err.code !== "EADDRNOTAVAIL") { if (err.code !== "EADDRNOTAVAIL" && err.code !== "EINVAL") {
logger.error(err); logger.error(err);
process.exit(1); process.exit(1);
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"test": "mocha --growl --timeout 20000 test test/fast test/fast/block test/integration test/", "test": "mocha --growl --timeout 20000 test test/fast test/fast/block test/integration test/",
"start": "node bin/ucoind start", "start": "node bin/ucoind start",
"test-travis": "node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec --timeout 20000 test test/fast test/fast/block test/integration test/", "test-travis": "node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec --timeout 20000 test test/fast test/fast/block test/integration test/",
"postinstall": "mkdir ui -p && cd ui && npm pack ucoin-ui@0.1.12 && tar xzf ucoin-ui-0.1.12.tgz && cd package && npm install && cd .. && rm ucoin-ui-0.1.12.tgz" "postinstall": "mkdir ui -p && cd ui && npm pack ucoin-ui@0.1.13 && tar xzf ucoin-ui-0.1.13.tgz && cd package && npm install && cd .. && rm ucoin-ui-0.1.13.tgz"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment