v++
Исправление зависания кнопки запуска сервера
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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", "всех операторов объявления");
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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","");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
//--
|
||||
|
||||
Reference in New Issue
Block a user