fix STOP server
authorNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 15:21:23 +0000 (17:21 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 15:21:23 +0000 (17:21 +0200)
src/be/nikiroo/fanfix/Main.java

index e48f4f53ec7ab7d1951ea4760cacdb64afbccc51..c02abb387c0309ad79a8cba66d79733af22a775a 100644 (file)
@@ -648,6 +648,18 @@ public class Main {
                                if (port == null)
                                        port = Instance.getInstance().getConfig().getInteger(Config.SERVER_PORT);
 
+                               if (host == null) {
+                                       String mode = Instance.getInstance().getConfig()
+                                                       .getString(Config.SERVER_MODE, "fanfix");
+                                       if ("http".equals(mode)) {
+                                               host = "http://localhost";
+                                       } else if ("https".equals(mode)) {
+                                               host = "https://localhost";
+                                       } else if ("fanfix".equals(mode)) {
+                                               host = "fanfix://localhost";
+                                       }
+                               }
+
                                if (port == null) {
                                        System.err.println("No port given nor configured in the config file");
                                        exitCode = 15;
@@ -1069,7 +1081,7 @@ public class Main {
         * @param key
         *            the key to contact the Fanfix server
         * @param host
-        *            the host on which it runs (NULL means localhost)
+        *            the host on which it runs
         * @param port
         *            the port on which it runs
         *            
@@ -1078,7 +1090,7 @@ public class Main {
         * @throws SSLException
         *             when the key was not accepted
         */
-       private void stopServer(String key, String host, Integer port)
+       private void stopServer(String key, String host, int port)
                        throws IOException, SSLException {
                if (host.startsWith("http://") || host.startsWith("https://")) {
                        new WebLibrary(key, host, port).stop();