Commit b9b8230e authored by 智勇's avatar 智勇
parents c2aef547 faf42d58
...@@ -30,6 +30,8 @@ var attrComsArr = []; ...@@ -30,6 +30,8 @@ var attrComsArr = [];
for(let i of attrComs){ for(let i of attrComs){
attrComsArr.push(attrs[i]); attrComsArr.push(attrs[i]);
} }
// 获取节点命令
admin.get('/get_node_command/:name', function (req, res) { admin.get('/get_node_command/:name', function (req, res) {
res.setHeader("Content-Type","application/json"); res.setHeader("Content-Type","application/json");
var str = execSync(`node ./get_project_config.js -name ${req.params.name} -attr config_file/command/gitPathHead`) var str = execSync(`node ./get_project_config.js -name ${req.params.name} -attr config_file/command/gitPathHead`)
...@@ -40,6 +42,8 @@ admin.get('/get_node_command/:name', function (req, res) { ...@@ -40,6 +42,8 @@ admin.get('/get_node_command/:name', function (req, res) {
res.send({configPath:config_file,buildCmd:command,gitGroup:gitGroup}); res.send({configPath:config_file,buildCmd:command,gitGroup:gitGroup});
}); });
// 获取项目配置
admin.get('/get_project_attr/:name', function (req, res) { admin.get('/get_project_attr/:name', function (req, res) {
res.setHeader("Content-Type","application/json"); res.setHeader("Content-Type","application/json");
var comstr = attrComsArr.join("/"); var comstr = attrComsArr.join("/");
...@@ -60,6 +64,8 @@ admin.get('/get_project_attr/:name', function (req, res) { ...@@ -60,6 +64,8 @@ admin.get('/get_project_attr/:name', function (req, res) {
res.send(rs); res.send(rs);
}); });
// 获取所有域名
admin.get('/get_hosts', function (req, res) { admin.get('/get_hosts', function (req, res) {
res.setHeader("Content-Type","application/json"); res.setHeader("Content-Type","application/json");
var comstr = attrComsArr.join("/"); var comstr = attrComsArr.join("/");
...@@ -68,75 +74,74 @@ admin.get('/get_hosts', function (req, res) { ...@@ -68,75 +74,74 @@ admin.get('/get_hosts', function (req, res) {
res.send(items); res.send(items);
}); });
function parseStr2Json(str){
var a = {};
var strs = str.split(" ");
for(let i of strs){
if(i){
let os = i.split("|");
a[os[0]]={
name: os[0],
ip: os[1],
http: os[2],
https: os[3]
}
}
}
return a
}
function parseJson2Str(json){
var a = [];
let keys = Object.keys(json);
for(let k of keys){
a.push([
json[k].name,
json[k].ip,
json[k].http,
json[k].https
].join("|"))
}
return a.join(" ")
}
// 增加一个新的nginx映射
admin.post('/add_new_proxy', function (req, res) { admin.post('/add_new_proxy', function (req, res) {
let request = req.body; let request = req.body;
let new_namespace = request["namespace"],new_ip = request["ip"],new_ports=request["proxy_ports"];
var str = String(execSync(`cat ../ngrok/docker_env_name.sh`)).replace(/\n/,""); var str = String(execSync(`cat ../ngrok/docker_env_name.sh`)).replace(/\n/,"");
console.log(str) let data = parseStr2Json(str);
var index = str.indexOf(request["namespace"]) data[new_namespace] = {
console.log(index) name: new_namespace,
let newstr = "",sourcestr; ip: new_ip,
if( index != -1 ){ http: new_ports.http_port,
//存在这个配置,判断是否是原有的IP https: new_ports.https_port
var reg = new RegExp(request["namespace"] + "\\|\\d*\\.\\d*\\.\\d*\\.\\d*\S*");
try{
sourcestr = str.match(reg);
sourcestr = sourcestr[0]
}catch(e){
res.send({msg:"错误,请检查 docket_env_name.sh 文件"})
return
} }
// proxy_ports = { let s = parseJson2Str(data)
// "http_port": http_port, s = s.replace("\n","")
// "https_port": https_port execSync(`echo "${s}" > ../ngrok/docker_env_name.sh`)
// }
console.log(request)
if(sourcestr != undefined){
var items = sourcestr.split("|");
if(items[1] == request["ip"]){
res.send({msg:"已经存在的配置"});
return
}else{
console.log("update new")
targetstr = request["namespace"] + "|" + request["ip"] + "|" + request["proxy_ports"]["http_port"]+ "|" + request["proxy_ports"]["https_port"] + " ";
newstr = str.replace(sourcestr,targetstr);
}
}else{
res.send({msg:"错误1"})
return
}
}else{
console.log("add new")
newstr = str + " " + request["namespace"] + "|" + request["ip"] + "|" + request["proxy_ports"]["http_port"]+ "|" + request["proxy_ports"]["https_port"] + " ";
//文件添加到这里面
}
newstr = newstr.replace(/\n/,"");
console.log(newstr)
execSync(`echo "${newstr}" > ../ngrok/docker_env_name.sh`)
cproc.exec("../ngrok/make_frp_ini_V2.sh"); cproc.exec("../ngrok/make_frp_ini_V2.sh");
res.send({msg:"执行完成"}); res.send({msg:"执行完成"});
}); });
// 删除一个namespace映射
admin.post('/remove_proxy', function (req, res) { admin.post('/remove_proxy', function (req, res) {
let request = req.body; let request = req.body;
let new_namespace = request["namespace"];
var str = String(execSync(`cat ../ngrok/docker_env_name.sh`)).replace(/\n/,""); var str = String(execSync(`cat ../ngrok/docker_env_name.sh`)).replace(/\n/,"");
var sourcestr; let data = parseStr2Json(str);
var reg = new RegExp(request["namespace"] + "\\|\\d*\\.\\d*\\.\\d*\\.\\d*\S*"); delete data[new_namespace]
try{ let s = parseJson2Str(data)
sourcestr = str.replace(reg,""); s = s.replace("\n","")
}catch(e){ execSync(`echo "${s}" > ../ngrok/docker_env_name.sh`)
res.send({msg:"错误,请检查 docket_env_name.sh 文件"}) cproc.exec("../ngrok/make_frp_ini_V2.sh");
return res.send({msg:"执行完成"});
}
execSync(`echo "${sourcestr}" > ../ngrok/docker_env_name.sh`);
cproc.exec(`../ngrok/remove.sh ${request["namespace"]}`);
res.setHeader("Content-Type","application/json");
var str = execSync(`cat ../ngrok/docker_env_name.sh`)
res.send({namespace:String(str)});
}); });
// 获取现有映射关系
admin.get('/get_proxy', function (req, res) { admin.get('/get_proxy', function (req, res) {
res.setHeader("Content-Type","application/json"); res.setHeader("Content-Type","application/json");
var str = execSync(`cat ../ngrok/docker_env_name.sh`) var str = execSync(`cat ../ngrok/docker_env_name.sh`)
......
...@@ -134,9 +134,9 @@ tranceConfig ui "wechattest.xyqb.com" "wechattest1.xyqb.com" "192.168.4.22" "xyq ...@@ -134,9 +134,9 @@ tranceConfig ui "wechattest.xyqb.com" "wechattest1.xyqb.com" "192.168.4.22" "xyq
tranceConfig java "xyqb-user-ui-22.ss.xyqb.loan" "139.198.2.95:2243" "192.168.4.22" "xyqb-user2.properties" tranceConfig java "xyqb-user-ui-22.ss.xyqb.loan" "139.198.2.95:2243" "192.168.4.22" "xyqb-user2.properties"
tranceConfig java "wx89894cd83d117b26" "wxd019cd24f6edae9f" "192.168.4.22" "xyqb-user2.properties" tranceConfig java "wx89894cd83d117b26" "wxd019cd24f6edae9f" "192.168.4.22" "xyqb-user2.properties"
tranceConfig java "11fb7f6a8b8edf2776a72c2f5624229c" "79f4e915dd37690b17c2f8fd6e6023ad" "192.168.4.22" "xyqb-user2.properties" tranceConfig java "11fb7f6a8b8edf2776a72c2f5624229c" "79f4e915dd37690b17c2f8fd6e6023ad" "192.168.4.22" "xyqb-user2.properties"
tranceConfig ui "wx89894cd83d117b26" "wxd019cd24f6edae9f" "192.168.4.22" "xyqb-user-ui.js" tranceConfig ui "wx89894cd83d117b26" "wxd019cd24f6edae9f" "192.168.4.22" "new-xyqb-user-ui.js"
tranceConfig ui "11fb7f6a8b8edf2776a72c2f5624229c" "79f4e915dd37690b17c2f8fd6e6023ad" "192.168.4.22" "xyqb-user-ui.js" tranceConfig ui "11fb7f6a8b8edf2776a72c2f5624229c" "79f4e915dd37690b17c2f8fd6e6023ad" "192.168.4.22" "new-xyqb-user-ui.js"
tranceConfig ui "wx89894cd83d117b26" "wxd019cd24f6edae9f" "192.168.4.22" "activity-ui.js" tranceConfig ui "wx89894cd83d117b26" "wx5b2e77c58fdcf1a5" "192.168.4.22" "activity-ui.js"
#tranceConfig java "rabbitmq.connection.host=192.168.4.22" "rabbitmq.connection.host=192.168.4.152" "192.168.4.22" "baitiao.properties" #tranceConfig java "rabbitmq.connection.host=192.168.4.22" "rabbitmq.connection.host=192.168.4.152" "192.168.4.22" "baitiao.properties"
......
dongmeifeng|192.168.4.78|32093|32093 tower|192.168.4.78|30886|30084 zhanghong|192.168.4.77|31826|32324 dongmeifeng|192.168.4.78|32093|32093 tower|192.168.4.78|30886|30084 zhanghong|192.168.4.77|31826|32324 wangzhen|192.168.4.77|31809|30100 tianyawei|192.168.4.18|32060|31111 zhangbo|192.168.4.77|31091|32056 wangfei|192.168.4.18|32589|32182
#!/bin/bash #!/bin/bash
echo "不再用这个脚本" echo "不再用这个脚本"
return exit
pwd_path="/home/qa-deploy-utils/qa_shell_script" pwd_path="/home/qa-deploy-utils/qa_shell_script"
config_shell_path="$pwd_path" config_shell_path="$pwd_path"
config_server="$pwd_path/config_server" config_server="$pwd_path/config_server"
......
...@@ -68,7 +68,7 @@ function createNginxHttpAndSSLConf() ...@@ -68,7 +68,7 @@ function createNginxHttpAndSSLConf()
# addFrpcSub uanguang http 192.168.4 124 80 uanguang $filename # addFrpcSub uanguang http 192.168.4 124 80 uanguang $filename
# createNginxHttpAndSSLConf store 192.168.4.27 9000 $nginxname/store.conf # createNginxHttpAndSSLConf store 192.168.4.27 9000 $nginxname/store.conf
createNginxHttpAndSSLConf h5 h5 192.168.4.25 7051 7051 $nginxname/base.conf createNginxHttpAndSSLConf h5 h5 192.168.4.24 7051 7051 $nginxname/base.conf
createNginxHttpAndSSLConf mock mock 192.168.4.27 80 80 $nginxname/base.conf createNginxHttpAndSSLConf mock mock 192.168.4.27 80 80 $nginxname/base.conf
createNginxHttpAndSSLConf atm atm 192.168.4.18 3000 3000 $nginxname/base.conf createNginxHttpAndSSLConf atm atm 192.168.4.18 3000 3000 $nginxname/base.conf
createNginxHttpAndSSLConf auth-center auth-center-38 192.168.4.193 8099 8099 $nginxname/base.conf createNginxHttpAndSSLConf auth-center auth-center-38 192.168.4.193 8099 8099 $nginxname/base.conf
...@@ -79,7 +79,7 @@ createNginxHttpAndSSLConf h5sp h5sp-25 192.168.4.25 7057 7057 $nginxname/base.co ...@@ -79,7 +79,7 @@ createNginxHttpAndSSLConf h5sp h5sp-25 192.168.4.25 7057 7057 $nginxname/base.co
createNginxHttpAndSSLConf qg1 qg1-21 192.168.4.21 9019 9019 $nginxname/base.conf createNginxHttpAndSSLConf qg1 qg1-21 192.168.4.21 9019 9019 $nginxname/base.conf
createNginxHttpAndSSLConf uanguang uanguang 192.168.4.124 80 80 $nginxname/base.conf createNginxHttpAndSSLConf uanguang uanguang 192.168.4.124 80 80 $nginxname/base.conf
createNginxHttpAndSSLConf store store 192.168.4.27 9000 9000 $nginxname/base.conf createNginxHttpAndSSLConf store store 192.168.4.27 9000 9000 $nginxname/base.conf
createNginxHttpAndSSLConf gongyucheng gongyucheng 192.168.4.254 80 80 $nginxname/base.conf
for ip_last in ${ips[@]} for ip_last in ${ips[@]}
do do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment