Skip to content

Commit

Permalink
- deployment strategy changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Areeb-Gillani committed Aug 18, 2024
1 parent 1d313cc commit b6c3ed8
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions src/main/java/io/github/areebgillani/boost/BoostApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ public class BoostApplication extends AbstractVerticle {
Vertx vertx;
JsonObject config;
Router router;
protected static BoostApplication instance;
public static BoostApplication getInstance(){
return instance;
}

@Override
public void start() throws Exception {
super.start();
vertx = Vertx.vertx();
router = Router.router(vertx);
loadConfig(null);
deploy();
instance = this;
}

public void init(Vertx vertx, Router router, String configPath) throws InterruptedException {
Expand Down Expand Up @@ -57,16 +60,18 @@ public void loadConfig(String folderPath) throws InterruptedException {
latch.await();
}

public void run() {
logger.info("Initializing Vertx Application Server...");
vertx.createHttpServer()
.requestHandler(router)
.listen(config().getInteger("http.port", 8080))
.onSuccess(server -> logger.info(("Server started at port [" + server.actualPort()+"]. ")))
.onFailure(failed -> logger.info(failed.getMessage()));
public void run(String folderPath, boolean isRestful) throws InterruptedException {
init(vertx, router, folderPath);
if(isRestful) {
logger.info("Initializing Vertx Application Server...");
vertx.createHttpServer()
.requestHandler(router)
.listen(config.getInteger("http.port", 8080))
.onSuccess(server -> logger.info(("Server started at port [" + server.actualPort() + "]. ")))
.onFailure(failed -> logger.info(failed.getMessage()));
}

}

public static void run(Class<? extends BoostApplication> clazz, String[] args) {
LinkedHashSet<String> params = new LinkedHashSet<>(List.of(new String[]{"run", clazz.getCanonicalName(), "--launcher-class=" + clazz.getCanonicalName()}));
params.addAll(List.of(args));
Expand All @@ -93,4 +98,13 @@ public ConfigRetrieverOptions initRetrieverConfig(String folderPath) {
.setConfig(new JsonObject().put("path", folderPath==null||folderPath.isEmpty()?"config.json":folderPath)))
.addStore(new ConfigStoreOptions().setType("sys"));
}

@Override
public Vertx getVertx() {
return vertx;
}

public JsonObject getConfig() {
return config;
}
}

0 comments on commit b6c3ed8

Please sign in to comment.