X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=library%2FWebLibraryServer.java;h=22f36e91f5729a7bfef72fe9c98d2a7fa157a6ec;hp=50dc3d942dcf39aeeadeb68d88c58a714e7551cf;hb=002972e9de731678035d56304d75a6d9e8233635;hpb=6d465e886ae46c9da99117cc4302948f700a51c4 diff --git a/library/WebLibraryServer.java b/library/WebLibraryServer.java index 50dc3d9..22f36e9 100644 --- a/library/WebLibraryServer.java +++ b/library/WebLibraryServer.java @@ -110,7 +110,7 @@ public class WebLibraryServer extends WebLibraryServerHtml { return NanoHTTPD.newFixedLengthResponse(Status.SERVICE_UNAVAILABLE, NanoHTTPD.MIME_PLAINTEXT, "Server is already exiting..."); } - + exiting = true; Instance.getInstance().getTraceHandler().trace("Exiting"); @@ -131,6 +131,20 @@ public class WebLibraryServer extends WebLibraryServerHtml { 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"); } @@ -341,7 +355,7 @@ public class WebLibraryServer extends WebLibraryServerHtml { 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..."); @@ -426,7 +440,7 @@ public class WebLibraryServer extends WebLibraryServerHtml { 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..."); @@ -457,7 +471,7 @@ public class WebLibraryServer extends WebLibraryServerHtml { 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..."); @@ -529,7 +543,7 @@ public class WebLibraryServer extends WebLibraryServerHtml { 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...");