2: Enable support for autostart of JupiterPerpsAlarmImpl
This commit is contained in:
@@ -16,10 +16,9 @@ public final class JupiterPerpsAlarmImpl {
|
||||
try {
|
||||
config = Config.parse(args, System.getenv());
|
||||
} catch (IllegalArgumentException exception) {
|
||||
System.err.println(exception.getMessage());
|
||||
printUsage();
|
||||
System.exit(2);
|
||||
return;
|
||||
String errMsg = "Could not parse configuration for JupiterPerpsAlarm: " + exception.getMessage() + "!";
|
||||
throw new IllegalStateException(errMsg, exception);
|
||||
}
|
||||
|
||||
if (config.selfTest()) {
|
||||
@@ -32,9 +31,8 @@ public final class JupiterPerpsAlarmImpl {
|
||||
try {
|
||||
definitions = AlarmConfigurationParser.parse(config.alarmConfiguration());
|
||||
} catch (Exception exception) {
|
||||
System.err.println("Could not load alarm configuration: " + exception.getMessage());
|
||||
System.exit(2);
|
||||
return;
|
||||
String errMsg = "Could not load alarm configuration: " + exception.getMessage() + "!";
|
||||
throw new IllegalStateException(errMsg, exception);
|
||||
}
|
||||
|
||||
List<AlarmAction> actions = new ArrayList<>();
|
||||
|
||||
@@ -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,19 +40,24 @@ public class NenjimHubImpl implements NenjimHub {
|
||||
}
|
||||
|
||||
private void startAutoRunProcesses() throws Exception {
|
||||
String[] processesToAutoStart = {
|
||||
startJupiterPerpsAlarm(); // TODO: Hardcoded/hacky way to auto-start but good enough for now.
|
||||
|
||||
"crypto.r35157.nenjim.NenjimHubSocketAdminAdapter",
|
||||
"crypto.r35157.nenjim.NenjimHubRestAdminAdapter",
|
||||
"crypto.r35157.nenjim.NenjimHubRPCAdminAdapter",
|
||||
"crypto.r35157.nenjim.SuwimoHub",
|
||||
"crypto.r35157.nenjim.SodaTaskManager",
|
||||
"crypto.r35157.assetaz.hub.AssetAZHub"
|
||||
// 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",
|
||||
//"crypto.r35157.nenjim.NenjimHubRestAdminAdapter",
|
||||
//"crypto.r35157.nenjim.NenjimHubRPCAdminAdapter",
|
||||
//"crypto.r35157.nenjim.SuwimoHub",
|
||||
//"crypto.r35157.nenjim.SodaTaskManager",
|
||||
//"crypto.r35157.assetaz.hub.AssetAZHub"
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user