use of io.github.quickmsg.common.config.BootstrapConfig in project smqtt by quickmsg.
the class AbstractStarter method start.
public static void start(String path) {
BootstrapConfig config = null;
if (path != null) {
if (path.endsWith(FileExtension.PROPERTIES_SYMBOL)) {
ObjectMapper mapper = new ObjectMapper(new JavaPropsFactory());
try {
config = mapper.readValue(new File(path), BootstrapConfig.class);
} catch (Exception e) {
log.error("properties read error", e);
}
} else if (path.endsWith(FileExtension.YAML_SYMBOL_1) || path.endsWith(FileExtension.YAML_SYMBOL_2)) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
try {
config = mapper.readValue(new File(path), BootstrapConfig.class);
} catch (Exception e) {
log.error("yaml read error", e);
return;
}
} else {
throw new NotSupportConfigException();
}
}
if (config == null) {
config = BootstrapConfig.defaultConfig();
}
Bootstrap.builder().rootLevel(Level.toLevel(config.getSmqttConfig().getLogLevel())).tcpConfig(config.getSmqttConfig().getTcpConfig()).httpConfig(config.getSmqttConfig().getHttpConfig()).websocketConfig(config.getSmqttConfig().getWebsocketConfig()).clusterConfig(config.getSmqttConfig().getClusterConfig()).redisConfig(config.getSmqttConfig().getRedisConfig()).databaseConfig(config.getSmqttConfig().getDatabaseConfig()).meterConfig(config.getSmqttConfig().getMeterConfig()).ruleChainDefinitions(config.getSmqttConfig().getRuleChainDefinitions()).sourceDefinitions(config.getSmqttConfig().getRuleSources()).aclConfig(config.getSmqttConfig().getAcl()).build().doOnStarted(AbstractStarter::printUiUrl).startAwait();
}
Aggregations