停服日志输出更新2

master
duhui 2021-06-22 10:47:37 +08:00
parent 49a85e2eb2
commit 98fe750cb3
1 changed files with 14 additions and 6 deletions

View File

@ -19,9 +19,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -264,16 +262,26 @@ public class ServerInfoController {
return wait;
}
String command = "sh " + path + " 210 " + serverInfo.getIP() + " " + serverInfo.getServer_id() + " " + serverInfo.getCoreName();
List<String> processList = new ArrayList<>();
try {
OutputStream stream = Runtime.getRuntime().exec(command).getOutputStream();
PrintStream printStream = new PrintStream(stream);
Process exec = Runtime.getRuntime().exec(command);
BufferedReader input = new BufferedReader(new InputStreamReader(exec.getInputStream()));
String line = "";
while ((line = input.readLine()) != null) {
processList.add(line);
}
System.out.printf("删除操作完成:命令:{%s}\n",command);
printStream.println();
wait = 0;
input.close();
} catch (IOException e) {
System.err.printf("删除操作失败:命令:{%s},报错:{%s}\n",command,e.getMessage());
e.printStackTrace();
}
System.out.println("========================== 停服脚本执行结果开始 ===========================");
processList.forEach(System.out::println);
System.out.println("=========================== 停服脚本执行结果结束 ==========================");
return wait;
}
}