From 7a4e79af4f116f81ac528b431aab1c5f92ef8d4a Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 1 Dec 2023 23:29:20 +0000 Subject: [PATCH] Add timer to shutdown procedure --- .../java/io/xpipe/app/core/mode/OperationMode.java | 12 ++++++++++-- .../java/io/xpipe/app/core/mode/PlatformMode.java | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java index 9c119298..4b939a80 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java @@ -230,9 +230,9 @@ public abstract class OperationMode { } public static void shutdown(boolean inShutdownHook, boolean hasError) { - // In case we are stuck while in shutdown, allow for an external kill command to instantly exit this application + // In case we are stuck while in shutdown, instantly exit this application if (inShutdown && inShutdownHook) { - TrackEvent.info("Received SIGTERM while in shutdown. Halting ..."); + TrackEvent.info("Received another shutdown request while in shutdown hook. Halting ..."); OperationMode.halt(1); } @@ -240,6 +240,14 @@ public abstract class OperationMode { return; } + // Run a timer to always exit after some time in case we get stuck + if (inShutdownHook) { + ThreadHelper.runAsync(() -> { + ThreadHelper.sleep(15000); + OperationMode.halt(1); + }); + } + inShutdown = true; OperationMode.inShutdownHook = inShutdownHook; try { diff --git a/app/src/main/java/io/xpipe/app/core/mode/PlatformMode.java b/app/src/main/java/io/xpipe/app/core/mode/PlatformMode.java index 1a2aae54..40fd633e 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/PlatformMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/PlatformMode.java @@ -43,6 +43,7 @@ public abstract class PlatformMode extends OperationMode { while (App.getApp() == null) { ThreadHelper.sleep(100); } + TrackEvent.info("mode", "Application startup finished ..."); // If we downloaded an update, and decided to no longer automatically update, don't remind us! // You can still update manually in the about tab