From ab67f93aa09c5c76547113cabb892db51b9b31eb5c650605d50cc239684f7152 Mon Sep 17 00:00:00 2001 From: Minimons Date: Fri, 19 Jun 2026 10:33:25 +0200 Subject: [PATCH] 2: Autostart JupiterPerpsAlarmImpl from NenjimHub using a named platform thread. --- .../r35157/nenjim/hubd/impl/ref/Main.tjava | 9 ++++--- .../nenjim/hubd/impl/ref/NenjimHubImpl.tjava | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava index b34f69f..4caa1e2 100644 --- a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava +++ b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava @@ -14,10 +14,13 @@ import java.nio.file.Files; import java.nio.file.Path; public class Main { - static void main(String[] args) throws Exception { - NenjimHub nenjimHub = new NenjimHubImpl(); -/* try { + // TODO: Consider if we really need a Main class or we just need to move the main method to NenjimHubImpl? + static void main(String[] args) throws Exception { + NenjimHubImpl nenjimHub = new NenjimHubImpl(); + nenjimHub.awaitShutdown(); + + /* try { log.info("Auto-starting 2 Nenjim application(s)..."); log.info(" Starting AssetAZCore..."); //com.r35157.; diff --git a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava index d84cad0..deb12f5 100644 --- a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava +++ b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava @@ -1,5 +1,6 @@ package com.r35157.nenjim.hubd.impl.ref; +import com.r35157.jupiterperpsalarm.impl.ref.JupiterPerpsAlarmImpl; import com.r35157.nenjim.hubd.NenjimHub; import com.r35157.nenjim.hubd.journal.Journal; import crypto.r35157.nenjim.NenjimProcess; @@ -8,6 +9,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.HashMap; +import java.util.concurrent.CountDownLatch; public class NenjimHubImpl implements NenjimHub { public NenjimHubImpl() throws Exception { @@ -38,6 +40,10 @@ public class NenjimHubImpl implements NenjimHub { } private void startAutoRunProcesses() throws Exception { + startJupiterPerpsAlarm(); // TODO: Hardcoded/hacky way to auto-start but good enough for now. + + // TODO: Old but more correct way to auto start plugins - but it is currently broken. + /* String[] processesToAutoStart = { //"com.r35157.jupiterperpsalarm.impl.ref.JupiterPerpsAlarmImpl" //"crypto.r35157.nenjim.NenjimHubSocketAdminAdapter", @@ -51,6 +57,7 @@ public class NenjimHubImpl implements NenjimHub { for (String processInterfaceName : processesToAutoStart) { startProcess(processInterfaceName); } + */ } @Override @@ -90,7 +97,27 @@ public class NenjimHubImpl implements NenjimHub { System.out.println("NenjimHub command: 'noop'"); } + public void awaitShutdown() throws InterruptedException { + shutdownLatch.await(); + } + + private void startJupiterPerpsAlarm() { + Thread thread = new Thread(() -> { + try { + JupiterPerpsAlarmImpl.main(new String[] { + "--config=conf/alarms.conf" + }); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + }, "Nenjim Plugin - JupiterPerpsAlarm"); + + thread.setDaemon(false); + thread.start(); + } + private static final Logger log = LoggerFactory.getLogger(NenjimHubImpl.class); + private final CountDownLatch shutdownLatch = new CountDownLatch(1); private HashMap processes; //private StructuredTaskScope.ShutdownOnFailure processesScope;