Исправление зависания кнопки запуска сервера
This commit is contained in:
2024-04-09 19:46:15 +03:00
parent 3d70efe253
commit e4fe527365
11 changed files with 29 additions and 43 deletions

11
.idea/workspace.xml generated
View File

@@ -7,17 +7,12 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/icons/versions/MatchHasErrors.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/icons/versions/NotMatchHasErrors.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Utils/Validators/ShellParser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Utils/Validators/ShellParser.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/GlobalData/Tasks/Supervisor/Remote/RemoteCompilationSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GlobalData/Tasks/Supervisor/Remote/RemoteCompilationSupervisor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/GlobalData/Tasks/Supervisor/Remote/ServerRunSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GlobalData/Tasks/Supervisor/Remote/ServerRunSupervisor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ProjectData/Messages/Message.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ProjectData/Messages/Message.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Component/Visualiser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Component/Visualiser.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/DVMTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/DVMTestingPlanner.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTasksPackage/UI/SapforPackageTreeNode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTasksPackage/UI/SapforPackageTreeNode.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/Group/GroupsDBTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/Group/GroupsDBTable.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/Test/TestDBTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/Test/TestDBTable.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -34,8 +34,8 @@
"InstructionPath": "",
"PerformanceAnalyzerPath": "",
"ComponentsBackUpsCount": 10,
"TestingKernels": 16,
"AutoCheckTesting": false,
"TestingKernels": 28,
"AutoCheckTesting": true,
"CheckTestingIntervalSeconds": 10,
"EmailOnTestingProgress": false,
"eraseTestingWorkspaces": true

View File

@@ -1,5 +1,4 @@
package GlobalData.Tasks.Supervisor.Remote;
import Common.UI.UI;
import Common.Utils.Utils;
import GlobalData.Makefile.Makefile;
import GlobalData.RemoteFile.RemoteFile;
@@ -30,7 +29,7 @@ public class RemoteCompilationSupervisor extends RemoteTaskSupervisor<Compilatio
}
@Override
protected void StartTask() throws Exception {
task.PID = pass.user.connection.startProcess(getRemoteProject(), getStartCommand());
task.PID = pass.user.connection.startShellProcess(getRemoteProject(), "PID",getStartCommand());
System.out.println("PID="+Utils.Brackets(task.PID));
task.state = TaskState.Running;
}

View File

@@ -17,7 +17,7 @@ public class ServerRunSupervisor extends RemoteTaskSupervisor<RunTask> {
String env = String.join(" ", Current.getRunConfiguration().getEnvList());
if (!env.isEmpty()) res = env + " " + res;
//--
task.PID = pass.user.connection.startProcess(getRemoteProject(),
task.PID = pass.user.connection.startShellProcess(getRemoteProject(),"PID",
"ulimit -s unlimited", res);
System.out.println("PID="+Utils.Brackets(task.PID));
task.state = TaskState.Running;

View File

@@ -35,7 +35,7 @@ public class Message extends FileObject {
codedMessages = new HashMap<>();
codedMessages2 = new HashMap<>();
codedMessages2.put("RR1_1", "перед");
codedMessages2.put("RR1_2", "объявлением переменных или");
codedMessages2.put("RR1_2", "объявлением переменных");
codedMessages2.put("RR1_3", "циклом");
codedMessages2.put("RR1_4", "после");
codedMessages2.put("RR1_5", "всех операторов объявления");

View File

@@ -62,7 +62,7 @@ public class Visualiser extends Component {
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
@Override
public void GetVersionInfo() {
version = 1093;
version = 1094;
String pattern = "MMM dd yyyy HH:mm:ss";
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
date_text = df.format(getClassBuildTime());

View File

@@ -134,7 +134,8 @@ public class GroupsDBTable extends iDBTable<Group> {
}
public Group getGroupByDescription(LanguageName language_in,String description_in) {
for (Group group : Data.values()) {
if (group.language.equals(language_in)&&group.description.equalsIgnoreCase(description_in))
if (group.sender_address.equals("vmk-post@yandex.ru")&&
group.language.equals(language_in)&&group.description.equalsIgnoreCase(description_in))
return group;
}
return null;

View File

@@ -102,7 +102,8 @@ public class TestDBTable extends iDBTable<Test> {
}
public Test getTestByDescription(int group_id_in, String description_in) {
for (Test test : Data.values()) {
if ((test.group_id==group_id_in)&&(test.description.equalsIgnoreCase(description_in)))
if (test.sender_address.equals("vmk-post@yandex.ru")&&
(test.group_id==group_id_in)&&(test.description.equalsIgnoreCase(description_in)))
return test;
}
return null;

View File

@@ -188,7 +188,7 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
Utils.DQuotes(testingPackage.kernels),
Utils.DQuotes(testingPackage.drv));
testingPackage.PID = user.connection.startProcess(packageRemoteWorkspace,
testingPackage.PID = user.connection.startShellProcess(packageRemoteWorkspace,"PID",
"ulimit -s unlimited", plannerStartCommand);
System.out.println("PID="+Utils.Brackets(testingPackage.PID));
RemoteFile STARTED = new RemoteFile(packageRemoteWorkspace, "STARTED");

View File

@@ -2,7 +2,6 @@ package TestingSystem.DVM;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import Common.Utils.Validators.ShellParser;
import GlobalData.Machine.Machine;
import GlobalData.RemoteFile.RemoteFile;
import GlobalData.User.User;
@@ -16,6 +15,7 @@ import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap;
import java.util.Vector;
public class UserConnection {
//http://www.jcraft.com/jsch/
public int iterations = 0; //для тестирования
//--
public ChannelSftp sftpChannel = null;
@@ -402,14 +402,6 @@ public class UserConnection {
execChannel.disconnect();
}
}
public void performScriptNoWait(RemoteFile directory, String... commands) throws Exception {
RemoteFile script_file = new RemoteFile(directory, Constants.script);
if (Exists(script_file))
sftpChannel.rm(script_file.full_name);
//--
writeToFile("cd " + Utils.DQuotes(directory.full_name) + "\n" + String.join("\n", commands), script_file);
CommandNoWait(Utils.DQuotes(script_file.full_name));
}
//-----
public void ShellConnect() throws Exception {
shellChannel = (ChannelShell) session.openChannel("shell");
@@ -474,20 +466,13 @@ public class UserConnection {
shellChannel = null;
System.gc();
}
public void ShellCommandNoWait(String command) throws Exception {
ShellConnect();
pin.write(("nohup " + command + " &\r\n").getBytes());
ShellParser.ReadCommand(command, fromServer); //команда
System.out.println("+++++++++++++++++");
ShellParser.ReadCommand(command, fromServer); //эхо
ShellDisconnect();
}
public String startProcess(RemoteFile directory, String... commands) throws Exception {
//возможно в дальнейшем обобщить чтобы вместо PID был файл вывода с задаваемым именем?
public String startShellProcess(RemoteFile directory, String outFileName, String... commands) throws Exception {
Vector<String> commands_ = new Vector<>();
commands_.add("cd " + Utils.DQuotes(directory.full_name));
for (int i = 0; i < commands.length; ++i) {
if (i == commands.length - 1) {
commands_.add(commands[i] + " 1>PID");
commands_.add(commands[i] + " 1>"+Utils.DQuotes(outFileName));
} else {
commands_.add(commands[i]);
}
@@ -498,14 +483,14 @@ public class UserConnection {
writeToFile(String.join("\n", commands_), script_file);
String start_command = Utils.DQuotes(script_file.full_name);
//--
RemoteFile PID = new RemoteFile(directory, "PID");
RemoteFile outFile = new RemoteFile(directory, outFileName);
ShellConnect();
pin.write(("nohup " + start_command + " &\r\n").getBytes());
while (!Exists(PID)){
System.out.println("PID NOT FOUND");
while (!Exists(outFile)){
System.out.println(outFileName +" NOT FOUND");
Utils.sleep(1000);
}
ShellDisconnect();
return readFromFile(PID).replace("\n","").replace("\r","");
return readFromFile(outFile).replace("\n","").replace("\r","");
}
}

View File

@@ -2,6 +2,7 @@ package Visual_DVM_2021.Passes.SSH;
import Common.Constants;
import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
import GlobalData.Machine.Machine;
import GlobalData.Machine.MachineType;
@@ -40,14 +41,17 @@ public abstract class RepositoryServerSSHPass extends ConnectionPass {
}
//--
protected void StartServer() throws Exception {
user.connection.performScript(serverHome, "nohup java -jar " + getServerFileName()+
" &");
user.connection.startShellProcess(serverHome,Constants.STARTED, "java -jar " + getServerFileName());
//--
RemoteFile STARTED = new RemoteFile(serverHome, Constants.STARTED);
RemoteFile StartLog = new RemoteFile(serverHome, Constants.STARTED +
"_by_" +
Current.getAccount().email +
"_" +
new Date().toString()
);
user.connection.sftpChannel.rename(STARTED.full_name, StartLog.full_name);
user.connection.writeToFile("+", StartLog);
//--
RemoteFile[] files = new RemoteFile[]{
@@ -62,6 +66,7 @@ public abstract class RepositoryServerSSHPass extends ConnectionPass {
}
protected void ShutdownServer() throws Exception {
//--
// UI.Info("+");
RemoteFile INTERRUPT = new RemoteFile(serverHome, Constants.INTERRUPT);
RemoteFile ABORTED = new RemoteFile(serverHome, Constants.ABORTED);
//--