Update schedulers to use process's executable path for invocation
This commit is contained in:
@ -5,6 +5,8 @@ import com.leakyabstractions.result.core.Results;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.ProcessHandle;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -140,8 +142,12 @@ public class LinuxScheduler {
|
||||
throw new CronExpressionException("Message period not implemented: '" + settings.getMessagePeriod() + "'");
|
||||
}
|
||||
|
||||
// TODO: figure out actual invocation
|
||||
return scheduleString + " /home/nathanmcrae/personal_root/projects/numbers-station/run.sh --station \"" + settings.getName() + "\"";
|
||||
String processName = ManagementFactory.getRuntimeMXBean().getName();
|
||||
long pid = Long.parseLong(processName.split("@")[0]);
|
||||
ProcessHandle currentProcess = ProcessHandle.of(pid).orElseThrow();
|
||||
Path executablePath = currentProcess.info().command().map(Paths::get).orElseThrow();
|
||||
logger.info("Executable Path: " + executablePath);
|
||||
return scheduleString + " " + executablePath.toString() + " --station \"" + settings.getName() + "\"";
|
||||
}
|
||||
|
||||
public static class CronExpressionException extends Exception {
|
||||
|
Reference in New Issue
Block a user