changes (still bugs :c)
This commit is contained in:
@@ -53,7 +53,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
public int getWebserverPort() {
|
||||
return this.getIntProperty("web.port");
|
||||
return this.getIntProperty("webserver.port");
|
||||
}
|
||||
|
||||
public String getHomeDir() {
|
||||
@@ -86,7 +86,8 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
public int getIntProperty(String key) {
|
||||
return Integer.parseInt(config.getProperty(key));
|
||||
String value = config.getProperty(key);
|
||||
return value != null ? Integer.parseInt(value) : 10;
|
||||
}
|
||||
|
||||
public boolean getBooleanProperty(String key) {
|
||||
|
||||
@@ -6,12 +6,16 @@ import java.util.Set;
|
||||
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.Promise;
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.core.http.HttpMethod;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.Router;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import io.vertx.ext.web.handler.BodyHandler;
|
||||
import io.vertx.ext.web.handler.CorsHandler;
|
||||
import io.vertx.jdbcclient.JDBCConnectOptions;
|
||||
import io.vertx.jdbcclient.JDBCPool;
|
||||
import io.vertx.sqlclient.PoolOptions;
|
||||
import net.miarma.contaminus.common.ConfigManager;
|
||||
import net.miarma.contaminus.common.Constants;
|
||||
import net.miarma.contaminus.database.DatabaseManager;
|
||||
@@ -23,9 +27,20 @@ public class DataLayerAPIVerticle extends AbstractVerticle {
|
||||
private ConfigManager configManager;
|
||||
|
||||
|
||||
public DataLayerAPIVerticle(JDBCPool pool) {
|
||||
this.pool = pool;
|
||||
}
|
||||
public DataLayerAPIVerticle() {
|
||||
JDBCConnectOptions connectOptions = new JDBCConnectOptions()
|
||||
.setJdbcUrl(
|
||||
"jdbc:mariadb://" + configManager.getStringProperty("db.host") +
|
||||
":" + configManager.getStringProperty("db.port") + "/"
|
||||
)
|
||||
.setDatabase(configManager.getStringProperty("db.name"))
|
||||
.setUser(configManager.getStringProperty("db.user"))
|
||||
.setPassword(configManager.getStringProperty("db.pwd"));
|
||||
|
||||
PoolOptions poolOptions = new PoolOptions().setMaxSize(5);
|
||||
|
||||
pool = JDBCPool.pool(vertx, connectOptions, poolOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Promise<Void> startPromise) {
|
||||
|
||||
@@ -10,25 +10,30 @@ import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.DeploymentOptions;
|
||||
import io.vertx.core.Promise;
|
||||
import io.vertx.core.ThreadingModel;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.jdbcclient.JDBCPool;
|
||||
import io.vertx.core.Vertx;
|
||||
import net.miarma.contaminus.common.ConfigManager;
|
||||
import net.miarma.contaminus.common.Constants;
|
||||
|
||||
public class MainVerticle extends AbstractVerticle {
|
||||
static ConfigManager configManager;
|
||||
private JDBCPool pool;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void init() {
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
|
||||
init();
|
||||
|
||||
Vertx vertx = Vertx.vertx();
|
||||
vertx.deployVerticle(new MainVerticle(), res -> {
|
||||
if (res.succeeded()) {
|
||||
System.out.println("MainVerticle desplegado con éxito");
|
||||
} else {
|
||||
System.err.println("Fallo al desplegar MainVerticle: " + res.cause());
|
||||
res.cause().printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void init() {
|
||||
configManager = ConfigManager.getInstance();
|
||||
JsonObject dbConfig = new JsonObject()
|
||||
.put("jdbcUrl", configManager.getJdbcUrl())
|
||||
.put("username", configManager.getStringProperty("db.user"))
|
||||
.put("password", configManager.getStringProperty("db.pwd"))
|
||||
.put("max_pool_size", configManager.getIntProperty("db.poolSize"));
|
||||
|
||||
pool = JDBCPool.pool(vertx, dbConfig);
|
||||
initializeDirectories();
|
||||
copyDefaultConfig();
|
||||
}
|
||||
@@ -57,13 +62,10 @@ public class MainVerticle extends AbstractVerticle {
|
||||
|
||||
@Override
|
||||
public void start(Promise<Void> startPromise) {
|
||||
System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
|
||||
init();
|
||||
|
||||
final DeploymentOptions options = new DeploymentOptions();
|
||||
options.setThreadingModel(ThreadingModel.WORKER);
|
||||
|
||||
vertx.deployVerticle(new DataLayerAPIVerticle(pool), options, result -> {
|
||||
vertx.deployVerticle(new DataLayerAPIVerticle(), options, result -> {
|
||||
if(result.succeeded()) {
|
||||
Constants.LOGGER.info(String.format(
|
||||
"🟢 DataLayerAPIVerticle desplegado. (http://%s:%d)",
|
||||
|
||||
Reference in New Issue
Block a user