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

index 50dc3d942dcf39aeeadeb68d88c58a714e7551cf..22f36e91f5729a7bfef72fe9c98d2a7fa157a6ec 100644 (file)
@@ -110,7 +110,7 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                        return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE,
                                        NanoHTTPD.MIME_PLAINTEXT, "Server is already exiting...");
                }
                        return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE,
                                        NanoHTTPD.MIME_PLAINTEXT, "Server is already exiting...");
                }
-               
+
                exiting = true;
                Instance.getInstance().getTraceHandler().trace("Exiting");
 
                exiting = true;
                Instance.getInstance().getTraceHandler().trace("Exiting");
 
@@ -131,6 +131,20 @@ public class WebLibraryServer extends WebLibraryServerHtml {
 
                doStop();
 
 
                doStop();
 
+               new Thread(new Runnable() {
+                       @Override
+                       public void run() {
+                               try {
+                                       Thread.sleep(1500);
+                               } catch (InterruptedException e) {
+                               }
+
+                               Instance.getInstance().getTraceHandler()
+                                               .trace("Exit timeout: force-quit");
+                               System.exit(0);
+                       }
+               }, "Exit program after timeout of 1500 ms").start();
+
                return NanoHTTPD.newFixedLengthResponse(Status.OK,
                                NanoHTTPD.MIME_PLAINTEXT, "Exited");
        }
                return NanoHTTPD.newFixedLengthResponse(Status.OK,
                                NanoHTTPD.MIME_PLAINTEXT, "Exited");
        }
@@ -341,7 +355,7 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                        return NanoHTTPD.newFixedLengthResponse(Status.FORBIDDEN,
                                        NanoHTTPD.MIME_PLAINTEXT, "SET story part not allowed");
                }
                        return NanoHTTPD.newFixedLengthResponse(Status.FORBIDDEN,
                                        NanoHTTPD.MIME_PLAINTEXT, "SET story part not allowed");
                }
-               
+
                if (exiting) {
                        return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE,
                                        NanoHTTPD.MIME_PLAINTEXT, "Server is exiting...");
                if (exiting) {
                        return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE,
                                        NanoHTTPD.MIME_PLAINTEXT, "Server is exiting...");
@@ -426,7 +440,7 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                        return NanoHTTPD.newFixedLengthResponse(Status.FORBIDDEN,
                                        NanoHTTPD.MIME_PLAINTEXT, "Cover request not allowed");
                }
                        return NanoHTTPD.newFixedLengthResponse(Status.FORBIDDEN,
                                        NanoHTTPD.MIME_PLAINTEXT, "Cover request not allowed");
                }
-               
+
                if (exiting) {
                        return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE,
                                        NanoHTTPD.MIME_PLAINTEXT, "Server is exiting...");
                if (exiting) {
                        return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE,
                                        NanoHTTPD.MIME_PLAINTEXT, "Server is exiting...");
@@ -457,7 +471,7 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                        return NanoHTTPD.newFixedLengthResponse(Status.FORBIDDEN,
                                        NanoHTTPD.MIME_PLAINTEXT, "Import not allowed");
                }
                        return NanoHTTPD.newFixedLengthResponse(Status.FORBIDDEN,
                                        NanoHTTPD.MIME_PLAINTEXT, "Import not allowed");
                }
-               
+
                if (exiting) {
                        return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE,
                                        NanoHTTPD.MIME_PLAINTEXT, "Server is exiting...");
                if (exiting) {
                        return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE,
                                        NanoHTTPD.MIME_PLAINTEXT, "Server is exiting...");
@@ -529,7 +543,7 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                        return NanoHTTPD.newFixedLengthResponse(Status.FORBIDDEN,
                                        NanoHTTPD.MIME_PLAINTEXT, "Delete not allowed");
                }
                        return NanoHTTPD.newFixedLengthResponse(Status.FORBIDDEN,
                                        NanoHTTPD.MIME_PLAINTEXT, "Delete not allowed");
                }
-               
+
                if (exiting) {
                        return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE,
                                        NanoHTTPD.MIME_PLAINTEXT, "Server is exiting...");
                if (exiting) {
                        return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE,
                                        NanoHTTPD.MIME_PLAINTEXT, "Server is exiting...");