diff --git a/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java b/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java index f6cdbd0..caa07b9 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java +++ b/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java @@ -25,14 +25,8 @@ public class LabyrinthServer { @NonNull private final Undertow undertow; - public static Option createAndStartServer() { - final Option serverOption = Try.of(ServerConfig::init) - .mapTry(LabyrinthServer::new) - .onFailure(cause -> log.error( - "Failed to create LabyrinthServer.", - cause - )) - .toOption(); + public static Try createAndStartServer() { + final Try serverOption = Try.of(ServerConfig::init).mapTry(LabyrinthServer::new); serverOption.forEach(LabyrinthServer::start); return serverOption; } diff --git a/src/main/java/ch/fritteli/labyrinth/server/Main.java b/src/main/java/ch/fritteli/labyrinth/server/Main.java index e11f627..fbdc645 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/Main.java +++ b/src/main/java/ch/fritteli/labyrinth/server/Main.java @@ -5,14 +5,6 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class Main { public static void main(String[] args) { - LabyrinthServer.createAndStartServer().onEmpty(() -> log.error("Failed to create server. Stopping.")); - -// final ServerConfig config = ServerConfig.init(); -// log.info("Starting Server at http://{}:{}/", config.getAddress().getHostAddress(), config.getPort()); -// Undertow.builder() -// .addHttpListener(config.getPort(), config.getAddress().getHostAddress()) -// .setHandler(UndertowPlayground.r) -// .build() -// .start(); + LabyrinthServer.createAndStartServer().onFailure(e -> log.error("Failed to create server. Stopping.", e)); } }