Skip to content

Commit

Permalink
- Server deployment methodolgy changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Areeb-Gillani committed Aug 18, 2024
1 parent b6c3ed8 commit 1ab8cdf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "io.github.areebgillani"
version = "0.0.13"
version = "0.0.14"
publishing {
publications {
create<MavenPublication>("maven") {
Expand Down
24 changes: 15 additions & 9 deletions src/main/java/io/github/areebgillani/boost/BoostApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

public class BoostApplication extends AbstractVerticle {
Logger logger = LoggerFactory.getLogger(BoostApplication.class);
Vertx vertx;
JsonObject config;
Router router;
private Vertx vertx;
private JsonObject config;
private Router router;
protected static BoostApplication instance;
public static BoostApplication getInstance(){
return instance;
Expand All @@ -45,28 +45,34 @@ public void init(Vertx vertx, Router router, JsonObject config) {
this.config = config;
deploy();
}
public void loadConfig(String folderPath) throws InterruptedException {
private void loadConfig(String folderPath) throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
ConfigRetriever.create(vertx, initRetrieverConfig(folderPath)).getConfig().onComplete(ar -> {
if (ar.failed()) {
latch.countDown();
logger.error("Error in config loading...!");
logger.error("Error in config loading!");
} else {
config = ar.result();
latch.countDown();
logger.info("Config loaded successfully..!");
logger.info("Config loaded successfully!");
}
});
latch.await();
}

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

0 comments on commit 1ab8cdf

Please sign in to comment.