2: Enable support for autostart of JupiterPerpsAlarmImpl
This commit is contained in:
@@ -16,10 +16,9 @@ public final class JupiterPerpsAlarmImpl {
|
|||||||
try {
|
try {
|
||||||
config = Config.parse(args, System.getenv());
|
config = Config.parse(args, System.getenv());
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
System.err.println(exception.getMessage());
|
|
||||||
printUsage();
|
printUsage();
|
||||||
System.exit(2);
|
String errMsg = "Could not parse configuration for JupiterPerpsAlarm: " + exception.getMessage() + "!";
|
||||||
return;
|
throw new IllegalStateException(errMsg, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.selfTest()) {
|
if (config.selfTest()) {
|
||||||
@@ -32,9 +31,8 @@ public final class JupiterPerpsAlarmImpl {
|
|||||||
try {
|
try {
|
||||||
definitions = AlarmConfigurationParser.parse(config.alarmConfiguration());
|
definitions = AlarmConfigurationParser.parse(config.alarmConfiguration());
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
System.err.println("Could not load alarm configuration: " + exception.getMessage());
|
String errMsg = "Could not load alarm configuration: " + exception.getMessage() + "!";
|
||||||
System.exit(2);
|
throw new IllegalStateException(errMsg, exception);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AlarmAction> actions = new ArrayList<>();
|
List<AlarmAction> actions = new ArrayList<>();
|
||||||
|
|||||||
@@ -14,10 +14,13 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class Main {
|
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("Auto-starting 2 Nenjim application(s)...");
|
||||||
log.info(" Starting AssetAZCore...");
|
log.info(" Starting AssetAZCore...");
|
||||||
//com.r35157.;
|
//com.r35157.;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.r35157.nenjim.hubd.impl.ref;
|
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.NenjimHub;
|
||||||
import com.r35157.nenjim.hubd.journal.Journal;
|
import com.r35157.nenjim.hubd.journal.Journal;
|
||||||
import crypto.r35157.nenjim.NenjimProcess;
|
import crypto.r35157.nenjim.NenjimProcess;
|
||||||
@@ -8,6 +9,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
public class NenjimHubImpl implements NenjimHub {
|
public class NenjimHubImpl implements NenjimHub {
|
||||||
public NenjimHubImpl() throws Exception {
|
public NenjimHubImpl() throws Exception {
|
||||||
@@ -38,19 +40,24 @@ public class NenjimHubImpl implements NenjimHub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startAutoRunProcesses() throws Exception {
|
private void startAutoRunProcesses() throws Exception {
|
||||||
String[] processesToAutoStart = {
|
startJupiterPerpsAlarm(); // TODO: Hardcoded/hacky way to auto-start but good enough for now.
|
||||||
|
|
||||||
"crypto.r35157.nenjim.NenjimHubSocketAdminAdapter",
|
// TODO: Old but more correct way to auto start plugins - but it is currently broken.
|
||||||
"crypto.r35157.nenjim.NenjimHubRestAdminAdapter",
|
/*
|
||||||
"crypto.r35157.nenjim.NenjimHubRPCAdminAdapter",
|
String[] processesToAutoStart = {
|
||||||
"crypto.r35157.nenjim.SuwimoHub",
|
//"com.r35157.jupiterperpsalarm.impl.ref.JupiterPerpsAlarmImpl"
|
||||||
"crypto.r35157.nenjim.SodaTaskManager",
|
//"crypto.r35157.nenjim.NenjimHubSocketAdminAdapter",
|
||||||
"crypto.r35157.assetaz.hub.AssetAZHub"
|
//"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) {
|
for (String processInterfaceName : processesToAutoStart) {
|
||||||
startProcess(processInterfaceName);
|
startProcess(processInterfaceName);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -90,7 +97,27 @@ public class NenjimHubImpl implements NenjimHub {
|
|||||||
System.out.println("NenjimHub command: 'noop'");
|
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 static final Logger log = LoggerFactory.getLogger(NenjimHubImpl.class);
|
||||||
|
private final CountDownLatch shutdownLatch = new CountDownLatch(1);
|
||||||
|
|
||||||
private HashMap<Integer, NenjimProcess> processes;
|
private HashMap<Integer, NenjimProcess> processes;
|
||||||
//private StructuredTaskScope.ShutdownOnFailure processesScope;
|
//private StructuredTaskScope.ShutdownOnFailure processesScope;
|
||||||
|
|||||||
Reference in New Issue
Block a user