feat: Dynamically set simulation log file path using OS temporary directory and remove isSimulationRunning method.

This commit is contained in:
2025-11-23 23:03:07 +00:00
parent 46d148c9d5
commit 5202032471

View File

@@ -95,18 +95,24 @@ public class SimulationProcessManager {
builder = new ProcessBuilder(javaBin, "-cp", classpath, className);
}
// this is a linux thing - not sure about windows
// get the OS temp folder
// Linux: /tmp/
// Windows: %AppData%\Local\Temp\
String tempDir = System.getProperty("java.io.tmpdir");
String logName = className.substring(className.lastIndexOf('.') + 1) + (arg != null ? "-" + arg : "") + ".log";
File logFile = new File("/tmp/" + logName);
// use the (File parent, String child) constructor to handle slash/backslash
// automatically
File logFile = new File(tempDir, logName);
builder.redirectOutput(logFile);
builder.redirectError(logFile);
Process process = builder.start();
runningProcesses.add(process);
System.out.println("Started " + className + (arg != null ? " " + arg : ""));
}
public boolean isSimulationRunning() {
return !runningProcesses.isEmpty() && runningProcesses.stream().anyMatch(Process::isAlive);
// print where the logs are actually going
System.out.println("Logs redirected to: " + logFile.getAbsolutePath());
}
}