Reshuffled init order to allow web server port modification

This commit is contained in:
Ziver Koc 2023-05-16 01:13:53 +02:00
parent b710626ad0
commit 070aeb35d7
2 changed files with 13 additions and 12 deletions

View file

@ -54,7 +54,7 @@ public class HalContext {
private static UserMessageManager messageManager = new UserMessageManager(); private static UserMessageManager messageManager = new UserMessageManager();
static { static {
// Set default values to get Hal up and running // Set default values to get Hal up and running before DB is read in
fileConf.setProperty(CONFIG_HTTP_PORT, "" + 8080); fileConf.setProperty(CONFIG_HTTP_PORT, "" + 8080);
} }

View file

@ -47,27 +47,28 @@ public class HalServer {
// Initialize Hal // Initialize Hal
// ------------------------------------ // ------------------------------------
// init logging // Init basic dependencies
LogUtil.readConfiguration("logging.properties"); LogUtil.readConfiguration("logging.properties");
HalContext.initialize();
DBConnection db = HalContext.getDB();
pluginManager = new PluginManager();
daemonExecutor = Executors.newScheduledThreadPool(1); // We set only one thread for easier troubleshooting for now
// Init core web server
http = new HttpServer(HalContext.getIntegerProperty(HalContext.CONFIG_HTTP_PORT)); http = new HttpServer(HalContext.getIntegerProperty(HalContext.CONFIG_HTTP_PORT));
http.setDefaultPage(new StartupWebPage()); http.setDefaultPage(new StartupWebPage());
http.start(); http.start();
// init variables
pluginManager = new PluginManager();
daemonExecutor = Executors.newScheduledThreadPool(1); // We set only one thread for easier troubleshooting for now
// Upgrade database // Upgrade database
logger.info("Working directory: " + FileUtil.find(".").getAbsolutePath());
HalDatabaseUpgradeManager.initialize(pluginManager); HalDatabaseUpgradeManager.initialize(pluginManager);
HalDatabaseUpgradeManager.upgrade(); HalDatabaseUpgradeManager.upgrade();
// init DB and other configurations // Init external web server
HalContext.initialize();
DBConnection db = HalContext.getDB();
logger.info("Working directory: " + FileUtil.find(".").getAbsolutePath());
httpExternal = new HalExternalWebDaemon(); httpExternal = new HalExternalWebDaemon();
registerDaemon(httpExternal); registerDaemon(httpExternal);