Add external program timeout as station setting
Leaving it without a UI implementation for now
This commit is contained in:
parent
645b1f2414
commit
553edc8b6c
@ -270,8 +270,8 @@ public class Main extends Application {
|
|||||||
switch (loadedStation.getMessageMethod()) {
|
switch (loadedStation.getMessageMethod()) {
|
||||||
case StationSettings.MessageMethod.EXTERNAL_PROGRAM:
|
case StationSettings.MessageMethod.EXTERNAL_PROGRAM:
|
||||||
Process process = new ProcessBuilder(loadedStation.getExternalProgramCommand(), nextMessagePath.toString()).start();
|
Process process = new ProcessBuilder(loadedStation.getExternalProgramCommand(), nextMessagePath.toString()).start();
|
||||||
// TODO: make timeout a setting
|
|
||||||
if (!process.waitFor(5, TimeUnit.SECONDS)) {
|
if (!process.waitFor(loadedStation.getExternalProgramTimeout().getSeconds(), TimeUnit.SECONDS)) {
|
||||||
throw new StationRunException("Timeout while running external program " + loadedStation.getExternalProgramCommand());
|
throw new StationRunException("Timeout while running external program " + loadedStation.getExternalProgramCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@ public class MainSettings {
|
|||||||
XmlMapper xmlMapper = new XmlMapper();
|
XmlMapper xmlMapper = new XmlMapper();
|
||||||
xmlMapper.registerModule(new JavaTimeModule());
|
xmlMapper.registerModule(new JavaTimeModule());
|
||||||
xmlMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
xmlMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
||||||
|
xmlMapper.configure(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS, false);
|
||||||
xmlMapper.enable(SerializationFeature.INDENT_OUTPUT);
|
xmlMapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||||
try {
|
try {
|
||||||
Path filePath = getSettingsFilePath();
|
Path filePath = getSettingsFilePath();
|
||||||
|
@ -10,6 +10,7 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.SimpleFileVisitor;
|
import java.nio.file.SimpleFileVisitor;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
@ -27,6 +28,7 @@ public class StationSettings {
|
|||||||
private String address;
|
private String address;
|
||||||
private int digitsPerGroup;
|
private int digitsPerGroup;
|
||||||
private String externalProgramCommand;
|
private String externalProgramCommand;
|
||||||
|
private Duration externalProgramTimeout;
|
||||||
private boolean manageScheduleExternally;
|
private boolean manageScheduleExternally;
|
||||||
private int messageLength;
|
private int messageLength;
|
||||||
private MessageMethod messageMethod;
|
private MessageMethod messageMethod;
|
||||||
@ -53,6 +55,7 @@ public class StationSettings {
|
|||||||
prefixes = new ArrayList<String>();
|
prefixes = new ArrayList<String>();
|
||||||
digitsPerGroup = 4;
|
digitsPerGroup = 4;
|
||||||
messageLength = 100;
|
messageLength = 100;
|
||||||
|
externalProgramTimeout = Duration.ofSeconds(5);
|
||||||
messageMethod = MessageMethod.SFTP;
|
messageMethod = MessageMethod.SFTP;
|
||||||
messagePeriod = MessagePeriod.DAILY;
|
messagePeriod = MessagePeriod.DAILY;
|
||||||
scheduleStart = ZonedDateTime.now();
|
scheduleStart = ZonedDateTime.now();
|
||||||
@ -62,6 +65,7 @@ public class StationSettings {
|
|||||||
name = newName;
|
name = newName;
|
||||||
prefixes = new ArrayList<String>();
|
prefixes = new ArrayList<String>();
|
||||||
digitsPerGroup = 4;
|
digitsPerGroup = 4;
|
||||||
|
externalProgramTimeout = Duration.ofSeconds(5);
|
||||||
messageLength = 100;
|
messageLength = 100;
|
||||||
messageMethod = MessageMethod.SFTP;
|
messageMethod = MessageMethod.SFTP;
|
||||||
messagePeriod = MessagePeriod.DAILY;
|
messagePeriod = MessagePeriod.DAILY;
|
||||||
@ -250,6 +254,14 @@ public class StationSettings {
|
|||||||
externalProgramCommand = newExternalProgramCommand;
|
externalProgramCommand = newExternalProgramCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Duration getExternalProgramTimeout() {
|
||||||
|
return externalProgramTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExternalProgramTimeout(Duration newExternalProgramTimeout) {
|
||||||
|
externalProgramTimeout = newExternalProgramTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getManageScheduleExternally() {
|
public boolean getManageScheduleExternally() {
|
||||||
return manageScheduleExternally;
|
return manageScheduleExternally;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user