2: Autostart JupiterPerpsAlarmImpl from NenjimHub using a named platform thread.

This commit is contained in:
2026-06-19 10:33:25 +02:00
parent 75cd15a20c
commit ab67f93aa0
2 changed files with 33 additions and 3 deletions
@@ -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.;
@@ -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<Integer, NenjimProcess> processes;
//private StructuredTaskScope.ShutdownOnFailure processesScope;