рефакторинг. Исправлен баг. если прервать локальную задачу, не удалялся файл interrupt.
This commit is contained in:
2024-01-08 20:37:16 +03:00
parent 5baf2154e2
commit fce61bf55a
26 changed files with 281 additions and 582 deletions

View File

@@ -16,10 +16,14 @@ public class ServerRunSupervisor extends RemoteTaskSupervisor<RunTask> {
String res = "./run";
String env = String.join(" ", Current.getRunConfiguration().getEnvList());
if (!env.isEmpty()) res = env + " " + res;
task.PID = pass.ShellCommand(
"cd " + Utils.DQuotes(getRemoteProject().full_name),
"ulimit -s unlimited",
res);
pass.user.connection.performScript(getRemoteProject(), "ulimit -s unlimited", res+" 1>PID");
RemoteFile PID = getPID();
while (!pass.user.connection.Exists(PID)){
System.out.println("PID NOT FOUND");
Utils.sleep(1000);
}
task.PID = pass.user.connection.readFromFile(PID).replace("\n","").replace("\r","");
System.out.println("PID="+Utils.Brackets(task.PID));
task.state = TaskState.Running;
}
@Override
@@ -32,21 +36,21 @@ public class ServerRunSupervisor extends RemoteTaskSupervisor<RunTask> {
//-------------------------
//удалить старую статистику если оная есть.
if (!task.last_sts_name.isEmpty()) {
pass.tryRM(new RemoteFile(getRemoteProject().full_name, task.last_sts_name));
pass.user.connection.tryRM(new RemoteFile(getRemoteProject().full_name, task.last_sts_name));
task.UpdateLastStsName("");
}
//-------------------------
String launchScriptText = getLaunchScriptText();
RemoteFile launchScript = new RemoteFile(getRemoteProject().full_name, "run");
pass.sftpChannel.put(
pass.user.connection.sftpChannel.put(
new ByteArrayInputStream(
launchScriptText.getBytes(StandardCharsets.UTF_8)), launchScript.full_name);
pass.sftpChannel.chmod(0777, launchScript.full_name);
pass.user.connection.sftpChannel.chmod(0777, launchScript.full_name);
//-
//отправить usr.par.
if (task.hasDVMPar()) {
File par_text = Utils.CreateTempFile("usr", String.join("\n", task.getRunConfiguration().getParList()));
pass.putSingleFile(par_text, new RemoteFile(getRemoteProject().full_name, "usr.par"));
pass.user.connection.putSingleFile(par_text, new RemoteFile(getRemoteProject().full_name, "usr.par"));
}
}
protected String getLaunchScriptText() {
@@ -62,7 +66,7 @@ public class ServerRunSupervisor extends RemoteTaskSupervisor<RunTask> {
task.parseCleanTime();
//теперь ищем статистику.
//статистика
Vector<ChannelSftp.LsEntry> files = pass.sftpChannel.ls(getRemoteProject().full_name);
Vector<ChannelSftp.LsEntry> files = pass.user.connection.sftpChannel.ls(getRemoteProject().full_name);
for (ChannelSftp.LsEntry file : files) {
if (file.getFilename().endsWith("sts.gz+")) {
task.UpdateLastStsName(file.getFilename());
@@ -71,7 +75,7 @@ public class ServerRunSupervisor extends RemoteTaskSupervisor<RunTask> {
}
if (!task.last_sts_name.isEmpty()) {
RemoteFile remote_sts = new RemoteFile(getRemoteProject().full_name, task.last_sts_name);
task.hasDvmSts = pass.tryGetSingleFileWithMaxSize(remote_sts, task.getLocalStsFile(), 10240);
task.hasDvmSts = pass.user.connection.tryGetSingleFileWithMaxSize(remote_sts, task.getLocalStsFile(), 10240);
}
}
}