generated from root/miduo_server
修改重启命令
parent
e5bb1bc1d9
commit
0a9be2fc5f
|
|
@ -230,27 +230,24 @@ public class AutoServerManager {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public int rebootServer(String serverId) throws Exception {
|
public int rebootServer(String serverId) throws Exception {
|
||||||
|
String path = "/data/jieling/reboot_core.sh";
|
||||||
|
|
||||||
ServerInfo serverInfo = serverInfoDao.getServerInfo(serverId);
|
ServerInfo serverInfo = serverInfoDao.getServerInfo(serverId);
|
||||||
if (serverInfo == null){
|
if (serverInfo == null){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtil.isEmpty(serverInfo.getIp()) || StringUtil.isEmpty(serverInfo.getCoreName())) {
|
String command = "sh " + path + " " + serverInfo.getIp() + " " + serverInfo.getCoreName();
|
||||||
LOGGER.error("重启命令操作参数不全,执行失败:参数:{}", serverInfo.toString());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
String command = "ansible "+ serverInfo.getIp() +" -m shell -a \"supervisorctl restart "+ serverInfo.getCoreName() +"\"";
|
|
||||||
LOGGER.info("重启命令:{}", command);
|
LOGGER.info("重启命令:{}", command);
|
||||||
|
|
||||||
int result = 0;
|
|
||||||
Process exec = null;
|
Process exec = null;
|
||||||
try {
|
try {
|
||||||
exec = Runtime.getRuntime().exec(command);
|
exec = Runtime.getRuntime().exec(command);
|
||||||
|
|
||||||
|
LOGGER.info("重启脚本执行结果开始");
|
||||||
readProcessOutput(exec);
|
readProcessOutput(exec);
|
||||||
LOGGER.info("===========================重启脚本执行结果结束");
|
LOGGER.info("重启脚本执行结果结束");
|
||||||
exec.waitFor();
|
exec.waitFor();
|
||||||
result = 1;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -258,7 +255,7 @@ public class AutoServerManager {
|
||||||
exec.destroy();
|
exec.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue