Feature: allow the client to shut down the computer at or after a certain time (#249)
A new -shutdown <time> option has been created to specify the time when the client will stop asking for new jobs, will finish uploading the frames in the upload queue and will shutdown the computer. The time argument can have two different formats: an absolute date & time in the format yyyy-MM-ddThh:mm:ss (24h format) or a relative time in the format +m where m is the number of minutes from now. The user can also select the shutdown-mode, where "wait" will wait for all the processes (render + pending uploads) to finish and "hard" will cancel all the pending jobs and will initiate the computer shutdown.
This commit is contained in:
@@ -227,4 +227,16 @@ public class Windows extends OS {
|
||||
// In windows, nice is not required and therefore we return always true to show the slider in the Settings GUI
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public void shutdownComputer(int delayInMinutes) {
|
||||
try {
|
||||
// Shutdown the computer, waiting 60 seconds, force app closure and on the shutdown screen indicate that was initiated by SheepIt app
|
||||
ProcessBuilder builder = new ProcessBuilder("shutdown", "/s", "/f", "/t", String.valueOf(delayInMinutes * 60), "/c", "\"SheepIt App has initiated this computer shutdown.\"");
|
||||
Process process = builder.inheritIO().start();
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.err.println(
|
||||
String.format("Windows::shutdownComputer Unable to execute the command 'shutdown /s /f /t 60...' command. Exception %s", e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user