From a2f55112fa760f155e12fbc57dca2f940418b7b9 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sat, 6 Jul 2024 18:06:25 -0400 Subject: [PATCH] only check port when the application is starting server --- src/main/java/com/gw/GeoweaverApplication.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gw/GeoweaverApplication.java b/src/main/java/com/gw/GeoweaverApplication.java index e1d18728..39cf3dfa 100644 --- a/src/main/java/com/gw/GeoweaverApplication.java +++ b/src/main/java/com/gw/GeoweaverApplication.java @@ -41,12 +41,6 @@ public class GeoweaverApplication { public static void main(String[] args) { - if (BaseTool.isPortInUse("localhost", BaseTool.get_current_port())) { - System.out.println("Port " + BaseTool.get_current_port() + " is already used. Cannot start Geoweaver."); - System.out.println("Could set the environment variable GEOWEAVER_PORT to another port and try again."); - System.exit(1); - } - // if we have a command line argument, we assume it is a command if (args.length > 0) { @@ -63,6 +57,12 @@ public static void main(String[] args) { } else { + if (BaseTool.isPortInUse("localhost", BaseTool.get_current_port())) { + System.out.println("Port " + BaseTool.get_current_port() + " is already used. Cannot start Geoweaver."); + System.out.println("Could set the environment variable GEOWEAVER_PORT to another port and try again."); + System.exit(1); + } + ApplicationContext applicationContext = new SpringApplicationBuilder(GeoweaverApplication.class) .bannerMode(Banner.Mode.OFF)