Commit 15af8ce5 authored by 智勇's avatar 智勇

适配

parent 4d49407e
...@@ -14,13 +14,8 @@ var param = { ...@@ -14,13 +14,8 @@ var param = {
projects = String(execSync(`curl -s http://127.0.0.1:10088/config_server/get_project_config_from_db`)) projects = String(execSync(`curl -s http://127.0.0.1:10088/config_server/get_project_config_from_db`))
projects = JSON.parse(projects) projects = JSON.parse(projects)
// console.log(typeof(projects)) // console.log(typeof(projects))
// console.log(projects)
for (var index in projects) { for (var index in projects) {
// if (projects[index]['project_name'] == 'xyqb') {
// console.log(index)
// console.log(projects[index])
// }
switch (projects[index]['type']) { switch (projects[index]['type']) {
case "java": case "java":
java_projects.push(projects[index]); java_projects.push(projects[index]);
...@@ -36,7 +31,7 @@ for (var index in projects) { ...@@ -36,7 +31,7 @@ for (var index in projects) {
break; break;
} }
} }
// console.log(111)
// // --java // // --java
// new pClass().init(1,true,"java", "7042", "xyqb-user2", "head_group", "xyqb-user2.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts", "-Denv=dev -Didc=default -Dtech.localhost= -Dtest=true", "用户注册登录-V2-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", ""); // new pClass().init(1,true,"java", "7042", "xyqb-user2", "head_group", "xyqb-user2.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts", "-Denv=dev -Didc=default -Dtech.localhost= -Dtest=true", "用户注册登录-V2-server", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
...@@ -64,32 +59,9 @@ function getListAttr(projects, attr) { ...@@ -64,32 +59,9 @@ function getListAttr(projects, attr) {
} }
var configFunction = function() {}; var configFunction = function() {};
configFunction.prototype = { configFunction.prototype = {
// getProjectAttr: function(pName, pAttr) {
// if (typeof projects[pName] == "undefined") {
// console.log("111")
// } else {
// console.log("222")
// var attrs = pAttr.split("/");
// if (attrs.length == 0) {
// console.log("")
// return
// }
// var list = [];
// for (var j = 0; j < attrs.length; j++) {
// if(projects[pName][attrs[j]]){
// console.log(projects)
// list.push(projects[pName][attrs[j]].split(" ").join("^"));
// }else{
// list.push(" ");
// }
// }
// console.log(list.join("|"))
// }
// },
getProjectAttr: function(pName, pAttr) { getProjectAttr: function(pName, pAttr) {
for (var index in projects) { for (var index in projects) {
if (projects[index]['project_name'] == pName) { if (projects[index]['name'] == pName) {
var attrs = pAttr.split("/"); var attrs = pAttr.split("/");
if (attrs.length == 0) { if (attrs.length == 0) {
console.log("") console.log("")
...@@ -104,40 +76,11 @@ configFunction.prototype = { ...@@ -104,40 +76,11 @@ configFunction.prototype = {
} }
} }
console.log(list.join("|")) console.log(list.join("|"))
} else {} } else {
}
} }
}, },
// getProjectsAttrs: function(projects, attr, attr2) {
// var attrs = attr.split("/");
// if (attrs.length == 0) {
// return
// }
// var list = [];
// //attr2 专有参数,用来表示是否要取带有对外域名的服务
// if(attr2 == "true"){
// for (var i = 0; i < projects.length; i++) {
// if(projects[i].url != ""){
// var li = [projects[i]["name"]];
// for (var j = 0; j < attrs.length; j++) {
// li.push(projects[i][attrs[j]]);
// }
// // li.push(projects[i].url);
// list.push(li.join("|"));
// }
// }
// }else{
// for (var i = 0; i < projects.length; i++) {
// // if (projects[i].is_active){
// var li = [projects[i]["name"]];
// for (var j = 0; j < attrs.length; j++) {
// li.push(projects[i][attrs[j]]);
// }
// list.push(li.join("|"));
// // }
// }
// }
// return list.join(" ");
// },
getProjectsAttrs: function(projects, attr, attr2) { getProjectsAttrs: function(projects, attr, attr2) {
var attrs = attr.split("/"); var attrs = attr.split("/");
if (attrs.length == 0) { if (attrs.length == 0) {
...@@ -148,7 +91,7 @@ configFunction.prototype = { ...@@ -148,7 +91,7 @@ configFunction.prototype = {
if (attr2 == "true") { if (attr2 == "true") {
for (var i = 0; i < projects.length; i++) { for (var i = 0; i < projects.length; i++) {
if (projects[i].url != "") { if (projects[i].url != "") {
var li = [projects[i]["project_name"]]; var li = [projects[i]["name"]];
for (var j = 0; j < attrs.length; j++) { for (var j = 0; j < attrs.length; j++) {
li.push(projects[i][attrs[j]]); li.push(projects[i][attrs[j]]);
} }
...@@ -159,7 +102,7 @@ configFunction.prototype = { ...@@ -159,7 +102,7 @@ configFunction.prototype = {
} else { } else {
for (var i = 0; i < projects.length; i++) { for (var i = 0; i < projects.length; i++) {
// if (projects[i].is_active){ // if (projects[i].is_active){
var li = [projects[i]["project_name"]]; var li = [projects[i]["name"]];
for (var j = 0; j < attrs.length; j++) { for (var j = 0; j < attrs.length; j++) {
li.push(projects[i][attrs[j]]); li.push(projects[i][attrs[j]]);
} }
......
...@@ -151,22 +151,22 @@ admin.get('/get_hosts', function(req, res) { ...@@ -151,22 +151,22 @@ admin.get('/get_hosts', function(req, res) {
}); });
// 根据类型获取系统名称 // 根据类型获取系统名称
admin.get('/get_systems_by_type', function (req, res) { admin.get('/get_systems_by_type', function(req, res) {
res.setHeader("Content-Type","application/json"); res.setHeader("Content-Type", "application/json");
var ui_str = execSync(`node ./get_project_config.js -type ui -attr name`) var ui_str = execSync(`node ./get_project_config.js -type ui -attr name`)
ui_str = String(ui_str) ui_str = String(ui_str)
.replace(/xyqb-ui/g,"").replace(/xjd-ui/,"xyqb-ui--xjd-ui") .replace(/xyqb-ui/g, "").replace(/xjd-ui/, "xyqb-ui--xjd-ui")
.replace(/new-paycenter-ui/g,"").replace(/paycenter-ui/,"paycenter-ui--new-paycenter-ui") .replace(/new-paycenter-ui/g, "").replace(/paycenter-ui/, "paycenter-ui--new-paycenter-ui")
.replace(/\s+/g,",").replace(/\n/g,"").slice(0, -1); .replace(/\s+/g, ",").replace(/\n/g, "").slice(0, -1);
var java_str = execSync(`node ./get_project_config.js -type java -attr name`) var java_str = execSync(`node ./get_project_config.js -type java -attr name`)
var node_str = execSync(`node ./get_project_config.js -type node -attr name`) var node_str = execSync(`node ./get_project_config.js -type node -attr name`)
var python_str = execSync(`node ./get_project_config.js -type python -attr name`) var python_str = execSync(`node ./get_project_config.js -type python -attr name`)
var server_str = `${String(java_str)} ${String(node_str)} ${String(python_str)}` var server_str = `${String(java_str)} ${String(node_str)} ${String(python_str)}`
server_str = server_str.replace(/\s+/g,",").replace(/\n/g,"").slice(0, -1);; server_str = server_str.replace(/\s+/g, ",").replace(/\n/g, "").slice(0, -1);;
res.send({ res.send({
common:"db,redis,rabbitmq,zookeeper", common: "db,redis,rabbitmq,zookeeper",
frontend:ui_str, frontend: ui_str,
backend:server_str backend: server_str
}); });
}); });
...@@ -268,17 +268,34 @@ admin.get('/get_project_config_from_db', function(req, res) { ...@@ -268,17 +268,34 @@ admin.get('/get_project_config_from_db', function(req, res) {
let proconfigs = db.collection('proconfigs'); let proconfigs = db.collection('proconfigs');
let projects = await proconfigs.find().toArray(); let projects = await proconfigs.find().toArray();
let re = []; let re = [];
// for (var i = 0; i < projects.length; i++) { for (var index = 0; index < projects.length; index++) {
// let project_name=projects[i]['project_name']; let temp = {
// let temp = { project_name: projects[i] }; name: projects[index]["project_name"],
// // temp[projects[i]['project_name']] = projects[i]; type: projects[index]["type"],
url: projects[index]["host_name"].replace(".xyqb.com", "").replace(".quantgroup.cn", ""),
www: projects[index]["host_name"],
git_path: projects[index]["git_path"],
config_path: projects[index]["config_path"],
log_name: projects[index]["log_path"],
command: projects[index]["start_command"],
command2: projects[index]["build_command"],
stop_command: projects[index]["stop_command"],
// command3: projects[index]["command3"],
// command4: projects[index]["command4"],
// command5: projects[index]["command5"],
port: projects[index]["port"],
desc: projects[index]["full_name"],
is_active: projects[index]["is_active"],
auth: projects[index]["auth"],
target_path: projects[index]["jar_path"]
}
// let project_name = projects[i]['project_name'];
// temp[projects[i]['project_name']] = projects[i];
// console.log(temp) // console.log(temp)
// re.push(temp); re.push(temp);
}
// }
db.close(); db.close();
res.send(projects) res.send(re)
}); });
} }
test(); test();
......
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