Updated Readme, Updated to the latest spark web REST Framework. Added

handling for spark initialization errors.
This commit is contained in:
Admin
2017-11-16 16:23:33 -06:00
parent fa00b7106a
commit 5eca809c4a
3 changed files with 18 additions and 14 deletions

View File

@@ -57,6 +57,7 @@ public class HABridge {
ipAddress(bridgeSettings.getBridgeSettingsDescriptor().getWebaddress());
// sparkjava config directive to set port for the web server to listen on
port(bridgeSettings.getBridgeSettingsDescriptor().getServerPort());
initExceptionHandler((e) -> HABridge.theExceptionHandler(e, bridgeSettings.getBridgeSettingsDescriptor().getServerPort()));
if(!bridgeSettings.getBridgeControl().isReinit())
init();
bridgeSettings.getBridgeControl().setReinit(false);
@@ -107,8 +108,7 @@ public class HABridge {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
log.error("Sleep error: " + e.getMessage());
}
}
}
@@ -118,4 +118,10 @@ public class HABridge {
log.info("HA Bridge (v" + theVersion.getVersion() + ") exiting....");
System.exit(0);
}
private static void theExceptionHandler(Exception e, Integer thePort) {
Logger log = LoggerFactory.getLogger(HABridge.class);
log.error("Could not start ha-bridge webservice on port [" + thePort + "] due to: " + e.getMessage());
System.exit(0);
}
}