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