From feab16e461575becf526d7c323936c0125a59ad9 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Thu, 14 Apr 2022 08:41:44 +0100 Subject: [PATCH] wait for router.isRunning when starting services. Exit if it fails to start --- core/src/main/groovy/com/muwire/core/Core.groovy | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index 9510f1c7..2b37db10 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -236,6 +236,7 @@ public class Core { routerProps.setProperty("i2np.upnp.ipv6.enable", i2pOptions.getProperty("i2np.upnp.ipv6.enable","true")) router = new Router(routerProps) router.getContext().setLogManager(new MuWireLogManager()) + router.setKillVMOnEnd(false) } log.info("initializing I2P socket manager") @@ -563,7 +564,13 @@ public class Core { if (router != null) { router.runRouter() - Thread.sleep(1000) + while(!router.isRunning()) { + Thread.sleep(100) + if (!router.isAlive()) { + log.severe("Router died while starting") + System.exit(0) // TODO: fire an event and let GUI know + } + } } i2pConnector.connect()