diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/Main.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/Main.java index 8a440025e..774b55dda 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/Main.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/Main.java @@ -50,13 +50,24 @@ public static void main(String[] args) { e.printStackTrace(); System.err.println("Failed to initialize Monitoring due to an exception: " + e.getMessage()); } - - /* Start Cineast CLI in interactive mode (blocking). */ - CLI.start(CineastCli.class); - - /* This part is only reached when user enters exit/quit: Stops the Cineast API endpoint. */ - APIEndpoint.stop(); - GRPCEndpoint.stop(); - PrometheusServer.stopServer(); + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + System.out.println("Shutting down endpoints..."); + APIEndpoint.stop(); + GRPCEndpoint.stop(); + PrometheusServer.stopServer(); + System.out.println("Goodbye!"); + })); + try { + /* Start Cineast CLI in interactive mode (blocking). */ + if (Config.sharedConfig().getApi().getEnableCli()) { + CLI.start(CineastCli.class); + } else { + while (true) { + Thread.sleep(100); + } + } + } catch (InterruptedException e) { + e.printStackTrace(); + } } } diff --git a/cineast.json b/cineast.json index ccab81b7c..5cb278488 100644 --- a/cineast.json +++ b/cineast.json @@ -85,7 +85,7 @@ }, "api": { - "enableCLI": true, + "enableCLI": false, "enableWebsocket": true, "enableWebsocketSecure": false, "enableRest": true,