...
|
...
|
@@ -219,6 +219,8 @@ var souMaxSize; |
|
|
var souBranch;
|
|
|
//原实例ip
|
|
|
var souInstanceIps;
|
|
|
//原实例ip,并且非保护
|
|
|
var souInstanceNoneProtectedIps;
|
|
|
var newInstanceIps;
|
|
|
var souProjectNames;
|
|
|
//修改伸缩组
|
...
|
...
|
@@ -233,6 +235,7 @@ function changeServer(scalingGroupId, groupName,awsGroupName, protectedFromCount |
|
|
souInstanceIps="";
|
|
|
newInstanceIps="";
|
|
|
souProjectNames="";
|
|
|
souInstanceNoneProtectedIps="";
|
|
|
|
|
|
$("#myModalLabel").text("");
|
|
|
$("#protectedFromCount").val("");
|
...
|
...
|
@@ -326,37 +329,133 @@ function changeOk(){ |
|
|
writeToText("获取原实例ip获取完成");
|
|
|
souProjectNames = getDeployProjectNames(scalingGroupName);
|
|
|
writeToText("该伸缩组部署的项目列表:"+souProjectNames);
|
|
|
$.ajax({
|
|
|
url: contextPath + 'autoScalingTool/modifyScalingGroup?cloudType=' + parseInt($("#cloudType").val()),
|
|
|
type: 'POST',
|
|
|
data: cloudParms,
|
|
|
dataType: 'json',
|
|
|
success: function (data) {
|
|
|
if (!data || data.code != 200) {
|
|
|
alert('修改伸缩组失败:'+data.message);
|
|
|
|
|
|
$("#myModalMessageLabel").text(scalingGroupName + ":正在 " + showMessage);
|
|
|
$("#myModalMessage").modal('show');
|
|
|
$("#myModalMessage").unbind("keyup");
|
|
|
$(".modal-backdrop").unbind("click");
|
|
|
|
|
|
$("#closeButton").attr("disabled","disabled");
|
|
|
|
|
|
//如果是缩容,并且如果是java项目的缩容,需要先停止非保护机器(kill相关机器的java项目进程,从zk中移除),再执行缩容,再拉起
|
|
|
if( "缩容"==showMessage){
|
|
|
if(scalingGroupName!="PCH5-memcache"&&scalingGroupName!="java-gateway-memcache"
|
|
|
&&scalingGroupName!="PCH5-AutoScaling"&&scalingGroupName!="PCH5-NODE"
|
|
|
&&scalingGroupName!="ELASTICSEARCH"&&scalingGroupName.indexOf("nginx")<0)
|
|
|
{
|
|
|
writeToText("java项目的缩容,需要先停止非受保护机器,请稍后...");
|
|
|
|
|
|
var paramStopNoneProtectedJava={};
|
|
|
paramStopNoneProtectedJava.cloudType=$("#cloudType").val();
|
|
|
paramStopNoneProtectedJava.groupName=aws_scalingGroupName;
|
|
|
paramStopNoneProtectedJava.groupId=souScalingGroupId;
|
|
|
paramStopNoneProtectedJava.projects=souProjectNames;
|
|
|
var rtnProcMsgId=stopNoneProtectedJavaProcessForUnDeploy(paramStopNoneProtectedJava);
|
|
|
|
|
|
if(rtnProcMsgId.length>0){
|
|
|
var count=0;
|
|
|
var urlMsg=contextPath + "/javaRestart/getMessageStatus";
|
|
|
var intervalIndex = setInterval(function() {
|
|
|
$.ajax({
|
|
|
url: urlMsg,
|
|
|
type: "post",
|
|
|
dataType: "json",
|
|
|
//async: false,
|
|
|
//timeout:120000, //超时时间:120秒
|
|
|
data: {
|
|
|
ids:rtnProcMsgId
|
|
|
},
|
|
|
success: function (checkResponse) {
|
|
|
count++;
|
|
|
if(checkResponse!=null&&checkResponse.code==200&&checkResponse.data=="ok"){
|
|
|
clearInterval(intervalIndex);
|
|
|
writeToText(">>>---stop ok!");
|
|
|
beginModifyScalingGroup(cloudParms,showMessage);
|
|
|
}else if(count > 30){
|
|
|
clearInterval(intervalIndex);
|
|
|
writeToText(">>>---超过规定的次数,直接跳过,进入下一步!");//3分钟
|
|
|
beginModifyScalingGroup(cloudParms,showMessage);
|
|
|
}else{
|
|
|
writeToText("..........*return process status >>>>>>"+checkResponse.data);
|
|
|
}
|
|
|
},
|
|
|
error: function (e) {
|
|
|
clearInterval(intervalIndex);
|
|
|
writeToText("getMessageStatus发生错误, 程序终止..........");
|
|
|
requestError(urlMsg);
|
|
|
}
|
|
|
});
|
|
|
}, 6000);
|
|
|
}else{
|
|
|
if(showMessage == "" || showMessage == undefined){
|
|
|
alert("修改基础信息成功!");
|
|
|
clear_Sour();
|
|
|
return;
|
|
|
}
|
|
|
$("#myModalMessageLabel").text(scalingGroupName + ":正在 " + showMessage);
|
|
|
$("#myModalMessage").modal('show');
|
|
|
$("#myModalMessage").unbind("keyup");
|
|
|
$(".modal-backdrop").unbind("click");
|
|
|
beginModifyScalingGroup(cloudParms,showMessage);
|
|
|
}
|
|
|
}else{
|
|
|
beginModifyScalingGroup(cloudParms,showMessage);
|
|
|
}
|
|
|
}else{
|
|
|
beginModifyScalingGroup(cloudParms,showMessage);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$("#closeButton").attr("disabled","disabled");
|
|
|
function beginModifyScalingGroup(cloudParms,showMessage) {
|
|
|
writeToText("开始修改伸缩组信息..........");
|
|
|
$.ajax({
|
|
|
url: contextPath + 'autoScalingTool/modifyScalingGroup?cloudType=' + parseInt($("#cloudType").val()),
|
|
|
type: 'POST',
|
|
|
data: cloudParms,
|
|
|
dataType: 'json',
|
|
|
success: function (data) {
|
|
|
if (!data || data.code != 200) {
|
|
|
alert('修改伸缩组失败:'+data.message);
|
|
|
}else{
|
|
|
if(showMessage == "" || showMessage == undefined){
|
|
|
alert("修改基础信息成功!");
|
|
|
clear_Sour();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//1:开始伸缩通知,成功扩容后才能执行下一步
|
|
|
refCloudMessage($("#cloudType").val(),showMessage, Math.abs(souDesiredCapacity - desiredCapacity),desiredCapacity);
|
|
|
//1:开始伸缩通知,成功扩容后才能执行下一步
|
|
|
refCloudMessage($("#cloudType").val(),showMessage, Math.abs(souDesiredCapacity - cloudParms.desiredCapacity),cloudParms.desiredCapacity);
|
|
|
}
|
|
|
},
|
|
|
error: function (e) {
|
|
|
alert('系统异常');
|
|
|
clear_Sour();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//调用java stop
|
|
|
function stopNoneProtectedJavaProcessForUnDeploy(paramFront) {
|
|
|
writeToText(">>> 非保护 java 项目停止,开始检查,请稍后...");
|
|
|
var url = contextPath + "/autoScalingTool/stopNoneProtectedJavaProcess";
|
|
|
var rtnProcMsgId="";
|
|
|
$.ajax({
|
|
|
url: url,
|
|
|
type: "post",
|
|
|
dataType: "json",
|
|
|
async: false,
|
|
|
data: paramFront,
|
|
|
success: function (response) {
|
|
|
if(response!=null&&response.code==200){
|
|
|
rtnProcMsgId=response.data.rtnProcMsgId;
|
|
|
var stopJavaFlag=response.data.stopJavaFlag;
|
|
|
writeToText(">>> java 项目停止,免于停止的受保护ip..."+response.data.protectedIps);
|
|
|
if("1"==stopJavaFlag){
|
|
|
souInstanceNoneProtectedIps=response.data.noneProtectedIps;
|
|
|
writeToText(">>> java 项目停止,停止的ip..."+response.data.noneProtectedIps);
|
|
|
writeToText(">>> java 项目停止,返回操作进程列表..."+rtnProcMsgId);
|
|
|
}else{
|
|
|
writeToText(">>> java 项目停止, 不存在需要停止的机器,此步骤跳过!");
|
|
|
}
|
|
|
},
|
|
|
error: function (e) {
|
|
|
alert('系统异常');
|
|
|
clear_Sour();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
error: function (e) {
|
|
|
requestError(url);
|
|
|
}
|
|
|
});
|
|
|
return rtnProcMsgId;
|
|
|
}
|
|
|
|
|
|
function clear_Sour(){
|
...
|
...
|
@@ -368,6 +467,7 @@ function clear_Sour(){ |
|
|
souInstanceIps ="";
|
|
|
newInstanceIps="";
|
|
|
souProjectNames="";
|
|
|
souInstanceNoneProtectedIps="";
|
|
|
}
|
|
|
|
|
|
//腾讯云:修改伸缩组后的下一个流程是查询伸缩活动
|
...
|
...
|
@@ -523,12 +623,62 @@ function unDeploy(showMessage){ |
|
|
}else if(scalingGroupName.indexOf("nginx")>=0){
|
|
|
updateNginxInfo(showMessage);
|
|
|
}else{
|
|
|
writeToText("正在更新git-iptables,请稍后...");
|
|
|
//缩java之前先把主机从zk移除,即调用java的stop服务
|
|
|
var suoProcessMsgId=stopJavaProcess();
|
|
|
//把之前停掉的机器启动
|
|
|
if(souInstanceNoneProtectedIps!=null&&souInstanceNoneProtectedIps.length>0){
|
|
|
writeToText("原stop的机器ip为 "+souInstanceNoneProtectedIps);
|
|
|
var restartProcessMsgId=restartJavaProcess();
|
|
|
if(restartProcessMsgId!=null&&restartProcessMsgId.length>0){
|
|
|
writeToText("等待java 进程重启,检查进程restartProcessMsgId "+restartProcessMsgId);
|
|
|
|
|
|
var urlMsg=contextPath + "/javaRestart/getMessageStatus";
|
|
|
var count=0;
|
|
|
var intervalIndex = setInterval(function() {
|
|
|
$.ajax({
|
|
|
url: urlMsg,
|
|
|
type: "post",
|
|
|
dataType: "json",
|
|
|
//async: false,
|
|
|
//timeout:120000, //超时时间:120秒
|
|
|
data: {
|
|
|
ids:restartProcessMsgId
|
|
|
},
|
|
|
success: function (checkResponse) {
|
|
|
count++;
|
|
|
if(checkResponse!=null&&checkResponse.code == 200&&checkResponse.data=="ok"){
|
|
|
clearInterval(intervalIndex);
|
|
|
writeToText(">>>---restart ok!");
|
|
|
//5:更新git文件
|
|
|
editToGit(showMessage);
|
|
|
}else if(count>=30){
|
|
|
clearInterval(intervalIndex);
|
|
|
writeToText(">>>---检查次数超过上线,直接跳过 !");
|
|
|
//5:更新git文件
|
|
|
editToGit(showMessage);
|
|
|
}else{
|
|
|
writeToText("..........*return process status >>>>>>"+checkResponse.data);
|
|
|
}
|
|
|
},
|
|
|
error: function (e) {
|
|
|
count++;
|
|
|
writeToText("Restart getMessageStatus发生错误,不影响整体步骤,继续");
|
|
|
//即使失败也继续进行
|
|
|
/*clearInterval(intervalIndex);
|
|
|
writeToText("getMessageStatus发生错误, 程序终止..........");
|
|
|
requestError(urlMsg);*/
|
|
|
}
|
|
|
});
|
|
|
}, 6000);
|
|
|
|
|
|
}else{
|
|
|
//5:更新git文件
|
|
|
editToGit(showMessage);
|
|
|
}
|
|
|
}else{
|
|
|
writeToText("不存在需要重启的机器,直接进入下一步 ");
|
|
|
//5:更新git文件
|
|
|
editToGit(showMessage);
|
|
|
}
|
|
|
|
|
|
//5:更新git文件
|
|
|
editToGit(showMessage);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -920,101 +1070,72 @@ function updateAnsibleDeployForNode_2_gitupstream(showMessage){ |
|
|
}
|
|
|
|
|
|
//调用java stop
|
|
|
function stopJavaProcess() {
|
|
|
writeToText(">>>java 项目 stop,请稍后...");
|
|
|
function restartJavaProcess() {
|
|
|
writeToText(">>>java 项目 restart,请稍后...");
|
|
|
|
|
|
var rtnProcMsgId="";
|
|
|
var suoIps="";
|
|
|
var tmpNewIps=newInstanceIps+",";
|
|
|
var array_souInstanceIps=souInstanceIps.split(",");
|
|
|
var array_souInstanceIps=souInstanceNoneProtectedIps.split(",");
|
|
|
for(var i=0;i<array_souInstanceIps.length;i++){
|
|
|
var oldTmpIp=array_souInstanceIps[i];
|
|
|
var tmpWithComm=oldTmpIp+",";
|
|
|
if(tmpNewIps.indexOf(tmpWithComm)<0){
|
|
|
if(tmpNewIps.indexOf(tmpWithComm)>=0){
|
|
|
if(suoIps.length>0){
|
|
|
suoIps+=",";
|
|
|
}
|
|
|
suoIps += oldTmpIp;
|
|
|
}
|
|
|
}
|
|
|
writeToText(">>>java 项目缩调的ip为:"+suoIps);
|
|
|
var url = contextPath + "/javaRestart/stopOrRestart";
|
|
|
var array_souProjectNames=souProjectNames.split(",");
|
|
|
var array_suoIps=suoIps.split(",");
|
|
|
for(var tmp_m=0;tmp_m<array_souProjectNames.length;tmp_m++)
|
|
|
{
|
|
|
for(var tmp_n=0;tmp_n<array_suoIps.length;tmp_n++)
|
|
|
if(suoIps.length<=0){
|
|
|
writeToText(">>>java进程 不存在需要重启拉起的机器!"+suoIps);
|
|
|
return "";
|
|
|
}else{
|
|
|
writeToText(">>>java进程 需要重启拉起的机器的ip为:"+suoIps);
|
|
|
var url = contextPath + "/javaRestart/stopOrRestart";
|
|
|
var array_souProjectNames=souProjectNames.split(",");
|
|
|
var array_suoIps=suoIps.split(",");
|
|
|
for(var tmp_m=0;tmp_m<array_souProjectNames.length;tmp_m++)
|
|
|
{
|
|
|
var project=array_souProjectNames[tmp_m];
|
|
|
var ip=array_suoIps[tmp_n];
|
|
|
writeToText(">>>开始java 项目 stop,..."+project+"--"+ip);
|
|
|
|
|
|
$.ajax({
|
|
|
url: url,
|
|
|
type: "post",
|
|
|
dataType: "json",
|
|
|
async: false,
|
|
|
data: {
|
|
|
cloud : "single",
|
|
|
exe :"stop",
|
|
|
ip :ip,
|
|
|
project :project
|
|
|
},
|
|
|
success: function (response) {
|
|
|
if(response!=null&&response.code==200){
|
|
|
if(rtnProcMsgId.length>0){
|
|
|
rtnProcMsgId += ",";
|
|
|
for(var tmp_n=0;tmp_n<array_suoIps.length;tmp_n++)
|
|
|
{
|
|
|
var project=array_souProjectNames[tmp_m];
|
|
|
var ip=array_suoIps[tmp_n];
|
|
|
writeToText(">>>开始java 项目 restart,..."+project+"--"+ip);
|
|
|
|
|
|
$.ajax({
|
|
|
url: url,
|
|
|
type: "post",
|
|
|
dataType: "json",
|
|
|
async: false,
|
|
|
data: {
|
|
|
cloud : "single",
|
|
|
exe :"restart",
|
|
|
ip :ip,
|
|
|
project :project
|
|
|
},
|
|
|
success: function (response) {
|
|
|
if(response!=null&&response.code==200){
|
|
|
if(rtnProcMsgId.length>0){
|
|
|
rtnProcMsgId += ",";
|
|
|
}
|
|
|
rtnProcMsgId += response.data[0].id;
|
|
|
}
|
|
|
rtnProcMsgId += response.data[0].id;
|
|
|
},
|
|
|
error: function (e) {
|
|
|
requestError(url);
|
|
|
}
|
|
|
},
|
|
|
error: function (e) {
|
|
|
requestError(url);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
writeToText(">>>java 项目 restart,返回操作进程列表:"+rtnProcMsgId);
|
|
|
return rtnProcMsgId;
|
|
|
}
|
|
|
writeToText(">>>java 项目 stop,返回操作进程列表:"+rtnProcMsgId);
|
|
|
|
|
|
|
|
|
//writeToText("java 项目 stop,..."+project+"--"+ip+"---执行进程:"+currentMsgId);
|
|
|
var urlMsg=contextPath + "/javaRestart/getMessageStatus";
|
|
|
var intervalIndex = setInterval(function() {
|
|
|
$.ajax({
|
|
|
url: urlMsg,
|
|
|
type: "post",
|
|
|
dataType: "json",
|
|
|
//async: false,
|
|
|
//timeout:120000, //超时时间:120秒
|
|
|
data: {
|
|
|
ids:rtnProcMsgId
|
|
|
},
|
|
|
success: function (checkResponse) {
|
|
|
if (!checkResponse || checkResponse.code != 200) {
|
|
|
clearInterval(intervalIndex);
|
|
|
writeToText("发生错误,getMessageStatus code 程序终止..........");
|
|
|
responseError(checkResponse);
|
|
|
}else{
|
|
|
if(checkResponse.data=="ok"){
|
|
|
clearInterval(intervalIndex);
|
|
|
writeToText(">>>---stop ok!");
|
|
|
}else{
|
|
|
writeToText("..........*return process status >>>>>>"+checkResponse.data);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
error: function (e) {
|
|
|
clearInterval(intervalIndex);
|
|
|
writeToText("getMessageStatus发生错误, 程序终止..........");
|
|
|
requestError(urlMsg);
|
|
|
}
|
|
|
});
|
|
|
}, 5000);
|
|
|
|
|
|
return rtnProcMsgId;
|
|
|
}
|
|
|
|
|
|
//5 和 6:ip写入git
|
|
|
function editToGit(showMessage){
|
|
|
writeToText("正在更新git-iptables,请稍后...");
|
|
|
var upDownFlag="up";//伸缩标志 :1 伸
|
|
|
if(showMessage != null && showMessage != undefined){
|
|
|
upDownFlag="down"; //缩减
|
...
|
...
|
|