...
|
...
|
@@ -102,6 +102,7 @@ |
|
|
<span class="input-group-addon">回滚:</span>
|
|
|
<input type="text" id="rollbackfile_name" name="rollbackfile_name" class="form-control"
|
|
|
readonly="readonly" value="${rollbackfile_name}"/>
|
|
|
<input type="hidden" id="workid_name" name="workid_name" readonly="readonly" value="${workid_name}"/>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
...
|
...
|
@@ -136,19 +137,19 @@ |
|
|
</div>
|
|
|
</c:forEach>
|
|
|
|
|
|
<c:if test="${existSpecialYohoSearchService=='error' or existSpecialYohoSearchService=='deregister'}">
|
|
|
<c:forEach items="${specialProjectLbList }" var="specialProject">
|
|
|
<div style="float: left;height: 600px;">
|
|
|
<hr>
|
|
|
|
|
|
<div>当前项目:<input type="text" value="yoho-search-service" readonly="readonly">
|
|
|
<div>当前项目:<input type="text" value="${specialProject}" readonly="readonly">
|
|
|
|
|
|
</div>
|
|
|
<div style="height: 50px" class="alert alert-warning" id="task-info-div_yoho-search-service">
|
|
|
<div style="height: 50px" class="alert alert-warning" id="task-info-div_${specialProject}">
|
|
|
</div>
|
|
|
<textarea id="resultArea_yoho-search-service" rows="25" cols="100"
|
|
|
<textarea id="resultArea_${specialProject}" rows="25" cols="100"
|
|
|
style="background-color: black; color: white" readonly="readonly"></textarea>
|
|
|
</div>
|
|
|
</c:if>
|
|
|
</c:forEach>
|
|
|
|
|
|
</div>
|
|
|
</div>
|
...
|
...
|
@@ -166,6 +167,8 @@ |
|
|
|
|
|
var myArray;
|
|
|
var removeArray = new Array();
|
|
|
var specialProjectLbList=${specialProjectLbList};
|
|
|
|
|
|
$(function () {
|
|
|
var messageListHidden = $("#messageListHidden").val();
|
|
|
myArray = messageListHidden.split(",");
|
...
|
...
|
@@ -217,32 +220,92 @@ |
|
|
});
|
|
|
}, 3000);
|
|
|
|
|
|
specialBuildYohoSearchService();
|
|
|
//特殊项目的发布
|
|
|
specialLbProject();
|
|
|
});
|
|
|
|
|
|
//特殊项目的发布
|
|
|
var yoho_search_service_resultAreaId="resultArea_yoho-search-service";
|
|
|
function specialBuildYohoSearchService(){
|
|
|
var existSpecialYohoSearchService="${existSpecialYohoSearchService}";
|
|
|
if("error"!=existSpecialYohoSearchService
|
|
|
&&"deregister"!=existSpecialYohoSearchService){
|
|
|
return;
|
|
|
|
|
|
function specialLbProject(){
|
|
|
for(var i=0; i<specialProjectLbList.length; i++){
|
|
|
var projectName=specialProjectLbList[i];
|
|
|
var resultAreaId="resultArea_"+projectName;
|
|
|
|
|
|
$.ajax({
|
|
|
url: contextPath + 'project/checkSpecialProjectLbInfoBeforeBuild',
|
|
|
type: 'POST',
|
|
|
data:{
|
|
|
project:projectName,
|
|
|
operate_name:$("#operate_name").val(),
|
|
|
environment_name:$("#environment_name").val(),
|
|
|
branch_name:$("#branch_name").val(),
|
|
|
workid_name:$("#workid_name").val(),
|
|
|
rollbackfile_name:$("#rollbackfile_name").val()
|
|
|
},
|
|
|
dataType: 'json',
|
|
|
success: function (reps) {
|
|
|
if(reps!=null&&reps.code==200){
|
|
|
var jsonLbResult = reps.data;
|
|
|
console.log(jsonLbResult);
|
|
|
if(jsonLbResult.onlyOneHost=="2"){
|
|
|
textAreaAppend(resultAreaId,"lb存在多台主机,特殊流程发布!");
|
|
|
|
|
|
singleSpecialLbProjectBuild(resultAreaId,jsonLbResult);
|
|
|
}else{
|
|
|
var dialog = $("<div>").appendTo($("body"));
|
|
|
dialog.dialog({
|
|
|
title: "提示",
|
|
|
backdrop: "static",
|
|
|
content: "负载均衡查询到一台或者没有机器实例,通过原流程发布",
|
|
|
buttons: [{
|
|
|
text: "否",
|
|
|
className: "btn-info",
|
|
|
onclick: function () {
|
|
|
textAreaAppend(resultAreaId,"发布取消!!");
|
|
|
document.getElementById("task-info-div_"+projectName).innerHTML = "<strong>发布取消</strong>";
|
|
|
dialog.dialog("hide");
|
|
|
}
|
|
|
}, {
|
|
|
text: "是",
|
|
|
className: "btn-danger",
|
|
|
onclick: function () {
|
|
|
dialog.dialog("hide");
|
|
|
textAreaAppend(resultAreaId,"lb最多只有一台主机,原流程直接发布!");
|
|
|
|
|
|
jsonLbResult.deployIps="";//要发布ip为空,则根据配置文件查找全部机器
|
|
|
var d=deployYohoSearchService(resultAreaId,jsonLbResult);
|
|
|
d.then(function () {
|
|
|
textAreaAppend(resultAreaId,"发布成功,完成!!");
|
|
|
document.getElementById("task-info-div_"+projectName).innerHTML = "<strong>发布成功</strong>";
|
|
|
return ;
|
|
|
});
|
|
|
}
|
|
|
}]
|
|
|
});
|
|
|
}
|
|
|
}else{
|
|
|
if(reps!=null){
|
|
|
textAreaAppend(resultAreaId,"lb检查出错,"+projectName+"项目发布终止!"+reps.message);
|
|
|
}else{
|
|
|
textAreaAppend(resultAreaId,"lb检查出错,"+projectName+"项目发布终止!");
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
error: function (e) {
|
|
|
textAreaAppend(resultAreaId,"lb检查出错,"+projectName+"项目发布终止!");
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonLbResult = JSON.parse('${specialYohoSearchServiceResult}');
|
|
|
console.log(jsonLbResult);
|
|
|
if("error"=="${existSpecialYohoSearchService}"){
|
|
|
textAreaAppendYohoSearchService(jsonLbResult.msg);
|
|
|
}else{
|
|
|
textAreaAppendYohoSearchService(jsonLbResult.msg);
|
|
|
function singleSpecialLbProjectBuild(resultAreaId,jsonLbResult) {
|
|
|
textAreaAppend(resultAreaId,jsonLbResult.msg);
|
|
|
//开始执行
|
|
|
textAreaAppendYohoSearchService(">>>>>开始执行>>>>>");
|
|
|
textAreaAppend(resultAreaId,">>>>>开始执行>>>>>");
|
|
|
//1.保留,卸载
|
|
|
textAreaAppendYohoSearchService("保留机器id is "+jsonLbResult.keepId);
|
|
|
textAreaAppendYohoSearchService("保留机器ip is "+jsonLbResult.keepIp);
|
|
|
textAreaAppendYohoSearchService("卸载机器id包含 "+jsonLbResult.changeIds);
|
|
|
textAreaAppendYohoSearchService("卸载机器ip包含 "+jsonLbResult.changeIps);
|
|
|
//2.查询卸载结果,等待卸载完成
|
|
|
//3.发布本次卸载的机器
|
|
|
//4.查询发布结果,发布完成之后,再挂载
|
...
|
...
|
@@ -251,68 +314,77 @@ |
|
|
//7.发布本次卸载的机器
|
|
|
//8.查询发布结果,发布完成之后,再挂载
|
|
|
//流程结束
|
|
|
textAreaAppend(resultAreaId,"保留机器id is "+jsonLbResult.keepId);
|
|
|
textAreaAppend(resultAreaId,"保留机器ip is "+jsonLbResult.keepIp);
|
|
|
textAreaAppend(resultAreaId,"卸载机器id包含 "+jsonLbResult.changeIds);
|
|
|
textAreaAppend(resultAreaId,"卸载机器ip包含 "+jsonLbResult.changeIps);
|
|
|
|
|
|
jsonLbResult.next_moveIds=jsonLbResult.changeIds;
|
|
|
var d=deregisterFromLb(resultAreaId,jsonLbResult);
|
|
|
|
|
|
jsonLbResult.deployIps=jsonLbResult.changeIps;
|
|
|
jsonLbResult.next_registerIds=jsonLbResult.changeIds;
|
|
|
jsonLbResult.next_moveIds=jsonLbResult.keepId;
|
|
|
jsonLbResult.lbHostNum=jsonLbResult.keepNum;
|
|
|
|
|
|
var d=checkDeregister(jsonLbResult);
|
|
|
d = d.then(function(){
|
|
|
jsonLbResult.deployIps=jsonLbResult.changeIps;
|
|
|
jsonLbResult.next_registerIds=jsonLbResult.changeIds;
|
|
|
jsonLbResult.next_moveIds=jsonLbResult.keepId;
|
|
|
jsonLbResult.lbHostNum=jsonLbResult.keepNum;
|
|
|
return checkDeregister(resultAreaId,jsonLbResult);
|
|
|
});
|
|
|
|
|
|
d = d.then(function(){
|
|
|
return deployYohoSearchService(jsonLbResult);
|
|
|
return deployYohoSearchService(resultAreaId,jsonLbResult);
|
|
|
});
|
|
|
|
|
|
d= d.then(function(){
|
|
|
//开始挂载到负载均衡
|
|
|
registerToLb(jsonLbResult.environmentName,jsonLbResult.next_registerIds);
|
|
|
registerToLb(resultAreaId,jsonLbResult,jsonLbResult.next_registerIds);
|
|
|
//挂载完成之后,负载均衡机器恢复卸载之前的状态,检查
|
|
|
jsonLbResult.lbHostNum=jsonLbResult.hostNum;
|
|
|
return checkDeregister(jsonLbResult);
|
|
|
return checkDeregister(resultAreaId,jsonLbResult);
|
|
|
});
|
|
|
|
|
|
d= d.then(function(){
|
|
|
deregisterFromLb(jsonLbResult);
|
|
|
deregisterFromLb(resultAreaId,jsonLbResult);
|
|
|
//卸载完成之后,再检查
|
|
|
jsonLbResult.deployIps=jsonLbResult.keepIp;
|
|
|
jsonLbResult.next_registerIds=jsonLbResult.next_moveIds;
|
|
|
jsonLbResult.next_moveIds="";
|
|
|
jsonLbResult.lbHostNum=jsonLbResult.changeNum;
|
|
|
return checkDeregister(jsonLbResult);
|
|
|
return checkDeregister(resultAreaId,jsonLbResult);
|
|
|
});
|
|
|
|
|
|
d=d.then(function () {
|
|
|
return deployYohoSearchService(jsonLbResult);
|
|
|
return deployYohoSearchService(resultAreaId,jsonLbResult);
|
|
|
});
|
|
|
|
|
|
d=d.then(function(){
|
|
|
//开始挂载到负载均衡
|
|
|
registerToLb(jsonLbResult.environmentName,jsonLbResult.next_registerIds);
|
|
|
registerToLb(resultAreaId,jsonLbResult,jsonLbResult.next_registerIds);
|
|
|
//挂载完成之后,负载均衡机器恢复卸载之前的状态,检查
|
|
|
jsonLbResult.lbHostNum=jsonLbResult.hostNum;
|
|
|
return checkDeregister(jsonLbResult);
|
|
|
return checkDeregister(resultAreaId,jsonLbResult);
|
|
|
});
|
|
|
|
|
|
d.then(function () {
|
|
|
textAreaAppendYohoSearchService("发布成功,完成!!");
|
|
|
document.getElementById("task-info-div_yoho-search-service").innerHTML = "<strong>发布成功</strong>";
|
|
|
textAreaAppend(resultAreaId,"发布成功,完成!!");
|
|
|
document.getElementById("task-info-div_"+jsonLbResult.currentProject).innerHTML = "<strong>发布成功</strong>";
|
|
|
return ;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//发布
|
|
|
function deployYohoSearchService(paramBackJson){
|
|
|
textAreaAppendYohoSearchService("*** 已经从负载均衡卸载下来的机器 : "+paramBackJson.deployIps);
|
|
|
var messageId = deployProject(paramBackJson);
|
|
|
textAreaAppendYohoSearchService("项目正在部署!messageId is "+messageId);
|
|
|
return deployProjectGetMsg(messageId,paramBackJson);
|
|
|
function deployYohoSearchService(resultAreaId,paramBackJson){
|
|
|
textAreaAppend(resultAreaId,"*** 即将发布的机器是 : "+paramBackJson.deployIps);
|
|
|
var messageId = deployProject(resultAreaId,paramBackJson);
|
|
|
textAreaAppend(resultAreaId,"项目正在部署!messageId is "+messageId);
|
|
|
return deployProjectGetMsg(resultAreaId,messageId,paramBackJson);
|
|
|
}
|
|
|
|
|
|
|
|
|
function deployProject(paramBackJson){
|
|
|
textAreaAppendYohoSearchService("开始部署项目");
|
|
|
|
|
|
function deployProject(resultAreaId,paramBackJson){
|
|
|
textAreaAppend(resultAreaId,"开始部署项目");
|
|
|
var returnMessageId = "";
|
|
|
var url = contextPath + 'project/buildProjectWithIPs';
|
|
|
var paramFront={};
|
...
|
...
|
@@ -331,7 +403,7 @@ |
|
|
async: false,
|
|
|
success: function (data) {
|
|
|
if (!data || data.code != 200) {
|
|
|
textAreaAppendYohoSearchService("发布失败");
|
|
|
textAreaAppend(resultAreaId,"发布失败");
|
|
|
}else{
|
|
|
//console.log("buildProjectWithIPs data is "+data.data);
|
|
|
returnMessageId = data.data.split(',')[0];
|
...
|
...
|
@@ -339,16 +411,16 @@ |
|
|
},
|
|
|
error: function (e) {
|
|
|
console.log(e);
|
|
|
textAreaAppendYohoSearchService("发布失败,error"+e);
|
|
|
textAreaAppend(resultAreaId,"发布失败,error"+e);
|
|
|
}
|
|
|
});
|
|
|
return returnMessageId;
|
|
|
}
|
|
|
|
|
|
//3.1:发布项目的同时获取发布的消息
|
|
|
function deployProjectGetMsg(msgId, paramBackJson){
|
|
|
function deployProjectGetMsg(resultAreaId,msgId, paramBackJson){
|
|
|
var def = $.Deferred();
|
|
|
textAreaAppendYohoSearchService("检查项目部署进度");
|
|
|
textAreaAppend(resultAreaId,"检查项目部署进度");
|
|
|
var intervalIndexMsg = setInterval(function() {
|
|
|
$.ajax({
|
|
|
url: contextPath + 'project/getbuildmsg?messageid=' + msgId+"&project="+paramBackJson.currentProject,
|
...
|
...
|
@@ -359,7 +431,7 @@ |
|
|
var obj2 = eval("(" + data3 + ")");
|
|
|
var messagedata = obj2.data;
|
|
|
if ((messagedata.message != "") && (messagedata.message != null) && (messagedata.message != undefined)) {
|
|
|
textAreaAppendYohoSearchService(messagedata.message);
|
|
|
textAreaAppend(resultAreaId,messagedata.message);
|
|
|
}
|
|
|
|
|
|
//code为2 ,则结束
|
...
|
...
|
@@ -367,7 +439,7 @@ |
|
|
//只有状态2,3,4才表示系统部署成功与否
|
|
|
if (code == 2 || code == 3 || code == 4) {
|
|
|
clearInterval(intervalIndexMsg);
|
|
|
textAreaAppendYohoSearchService("项目部署完成,状态 is "+code);
|
|
|
textAreaAppend(resultAreaId,"项目部署完成,状态 is "+code);
|
|
|
if(code==2){
|
|
|
//任务执行正常结束,只有这种情况,才能执行下一步操作。
|
|
|
def.resolve();
|
...
|
...
|
@@ -382,12 +454,13 @@ |
|
|
}
|
|
|
|
|
|
//卸载
|
|
|
function deregisterFromLb(paramBackJson) {
|
|
|
textAreaAppendYohoSearchService("卸载机器到elb"+paramBackJson.next_moveIds);
|
|
|
$.ajax({
|
|
|
function deregisterFromLb(resultAreaId,paramBackJson) {
|
|
|
textAreaAppend(resultAreaId,"从elb卸载机器 "+paramBackJson.next_moveIds);
|
|
|
return $.ajax({
|
|
|
url: contextPath+"/project/deregisterHostYohoSearchService",
|
|
|
type: "post",
|
|
|
data:{
|
|
|
project:paramBackJson.currentProject,
|
|
|
environment_name:paramBackJson.environmentName,
|
|
|
instIds:paramBackJson.next_moveIds
|
|
|
},
|
...
|
...
|
@@ -403,13 +476,14 @@ |
|
|
}
|
|
|
|
|
|
//挂载到负载均衡
|
|
|
function registerToLb(environment_name,instIds){
|
|
|
textAreaAppendYohoSearchService("挂载机器到elb "+instIds);
|
|
|
function registerToLb(resultAreaId,jsonLbResult,instIds){
|
|
|
textAreaAppend(resultAreaId,"挂载机器到elb "+instIds);
|
|
|
$.ajax({
|
|
|
url: contextPath+"/project/registerHostYohoSearchService",
|
|
|
type: "post",
|
|
|
data:{
|
|
|
environment_name:environment_name,
|
|
|
project:jsonLbResult.currentProject,
|
|
|
environment_name:jsonLbResult.environmentName,
|
|
|
instIds:instIds
|
|
|
},
|
|
|
dataType: "json",
|
...
|
...
|
@@ -426,27 +500,30 @@ |
|
|
|
|
|
|
|
|
//卸载检查
|
|
|
function checkDeregister(cbfParam){
|
|
|
function checkDeregister(resultAreaId,cbfParam){
|
|
|
var keepHostNum=cbfParam.lbHostNum;
|
|
|
var df = $.Deferred();
|
|
|
textAreaAppendYohoSearchService("**** 负载均衡实例数量检查 ***");
|
|
|
textAreaAppend(resultAreaId,"**** 负载均衡实例数量检查 ***");
|
|
|
var count=0;
|
|
|
var intervalIndex = setInterval(function() {
|
|
|
$.ajax({
|
|
|
url: contextPath+"/project/getLbInfoYohoSearchService?environment_name="+cbfParam.environmentName,
|
|
|
url: contextPath+"/project/getLbInfoYohoSearchService",
|
|
|
type: "post",
|
|
|
dataType: "json",
|
|
|
//async: false,
|
|
|
//timeout:120000, //超时时间:120秒
|
|
|
data: {},
|
|
|
data: {
|
|
|
project:cbfParam.currentProject,
|
|
|
environment_name:cbfParam.environmentName
|
|
|
},
|
|
|
success: function (checkResponse) {
|
|
|
count++;
|
|
|
if(count > 5){
|
|
|
textAreaAppendYohoSearchService("..........检查次数......"+(count-5));
|
|
|
textAreaAppend(resultAreaId,"..........检查次数......"+(count-5));
|
|
|
}
|
|
|
if(count > 105){
|
|
|
clearInterval(intervalIndex);
|
|
|
textAreaAppendYohoSearchService("**** 超过规定的次数,任务终止 ****");
|
|
|
textAreaAppend(resultAreaId,"**** 超过规定的次数,任务终止 ****");
|
|
|
}else if(checkResponse!=null&&checkResponse.code==200){
|
|
|
var currentHosts=0;
|
|
|
for(var hostid in checkResponse.data){
|
...
|
...
|
@@ -454,7 +531,7 @@ |
|
|
}
|
|
|
if(currentHosts==keepHostNum){
|
|
|
clearInterval(intervalIndex);
|
|
|
textAreaAppendYohoSearchService("**** 检查通过,负载均衡现有实例数量为: "+keepHostNum);
|
|
|
textAreaAppend(resultAreaId,"**** 检查通过,负载均衡现有实例数量为: "+keepHostNum);
|
|
|
df.resolve();
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -530,10 +607,6 @@ |
|
|
});
|
|
|
}
|
|
|
|
|
|
function textAreaAppendYohoSearchService(content) {
|
|
|
textAreaAppend(yoho_search_service_resultAreaId,content);
|
|
|
}
|
|
|
|
|
|
function textAreaAppend(textId,content) {
|
|
|
var d = $("#"+textId).val();
|
|
|
if(d!=null&&d.length>0){
|
...
|
...
|
|