Update schedulers to use process's executable path for invocation
This commit is contained in:
parent
670779a3aa
commit
c480239636
@ -5,6 +5,8 @@ import com.leakyabstractions.result.core.Results;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.lang.ProcessHandle;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@ -140,8 +142,12 @@ public class LinuxScheduler {
|
|||||||
throw new CronExpressionException("Message period not implemented: '" + settings.getMessagePeriod() + "'");
|
throw new CronExpressionException("Message period not implemented: '" + settings.getMessagePeriod() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: figure out actual invocation
|
String processName = ManagementFactory.getRuntimeMXBean().getName();
|
||||||
return scheduleString + " /home/nathanmcrae/personal_root/projects/numbers-station/run.sh --station \"" + settings.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 {
|
public static class CronExpressionException extends Exception {
|
||||||
|
@ -7,8 +7,11 @@ import java.io.BufferedWriter;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.lang.ProcessHandle;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -215,13 +218,19 @@ public class WindowsScheduler {
|
|||||||
Element exec = doc.createElement("Exec");
|
Element exec = doc.createElement("Exec");
|
||||||
actions.appendChild(exec);
|
actions.appendChild(exec);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
Element command = doc.createElement("Command");
|
Element command = doc.createElement("Command");
|
||||||
// TODO: need to figure out the real invocation
|
// TODO: need to figure out the real invocation
|
||||||
command.appendChild(doc.createTextNode("powershell"));
|
command.appendChild(doc.createTextNode(executablePath.toString()));
|
||||||
exec.appendChild(command);
|
exec.appendChild(command);
|
||||||
|
|
||||||
Element arguments = doc.createElement("Arguments");
|
Element arguments = doc.createElement("Arguments");
|
||||||
arguments.appendChild(doc.createTextNode("-Version 5 -NoProfile -File P:/personal_root/projects/numbers-station/run.ps1 --station \"" + station.getName() + "\""));
|
arguments.appendChild(doc.createTextNode("--station \"" + station.getName() + "\""));
|
||||||
exec.appendChild(arguments);
|
exec.appendChild(arguments);
|
||||||
|
|
||||||
return doc;
|
return doc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user