Commit a400b68d authored by 智勇's avatar 智勇

fix

parent 01510169
...@@ -36,7 +36,6 @@ app.use(bodyParser.urlencoded({ extended: false })) ...@@ -36,7 +36,6 @@ app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json()) app.use(bodyParser.json())
var attrs = { var attrs = {
configPath: "config_file", configPath: "config_file",
buildCmd: "command2",
gitPath: "git_path", gitPath: "git_path",
gitGroup: "gitPathHead", gitGroup: "gitPathHead",
host: "www", host: "www",
...@@ -47,9 +46,9 @@ var attrs = { ...@@ -47,9 +46,9 @@ var attrs = {
jarFilePath: "target_path", jarFilePath: "target_path",
auth: "auth", auth: "auth",
port: "port", port: "port",
start_command: "", buildCmd: "command2",
stop_command: "", startCmd: "command",
command2: "command", stopCmd: "stop_command",
node_version: "node_version" node_version: "node_version"
} }
var attrComs = Object.keys(attrs) var attrComs = Object.keys(attrs)
...@@ -131,10 +130,10 @@ function getProjectConfigPromise() { ...@@ -131,10 +130,10 @@ function getProjectConfigPromise() {
temp.command2 = pro["build_command"]; temp.command2 = pro["build_command"];
temp.command = pro["start_command"]; temp.command = pro["start_command"];
} else if (pro["type"] == "ui") { } else if (pro["type"] == "ui") {
temp.command2 = pro["build_command"]; temp.command2 = pro["build_command"];
} else if (pro["type"] == "node") { } else if (pro["type"] == "node") {
temp.command = pro["start_command"] temp.command = pro["start_command"]
temp.command2 = pro["stop_command"] temp.stop_command = pro["stop_command"]
} else if (pro["type"] == "python") { } else if (pro["type"] == "python") {
} }
...@@ -150,8 +149,8 @@ function getProjectConfigPromise() { ...@@ -150,8 +149,8 @@ function getProjectConfigPromise() {
function getProjectConfigPromiseByDb() { function getProjectConfigPromiseByDb() {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
// mongoose.model("ProConfig",new mongoose.Schema({})) // mongoose.model("ProConfig",new mongoose.Schema({}))
ProConfig.find({}).exec().then(res => { ProConfig.find({}).exec().then(res => {
// let _pros = JSON.parse(JSON.stringify(res)); // let _pros = JSON.parse(JSON.stringify(res));
resolve(res) resolve(res)
}).catch((err) => { }).catch((err) => {
reject(err) reject(err)
...@@ -361,46 +360,46 @@ admin.get('/get_namespace_by_type_for_jenkins/:_type', async function (req, res) ...@@ -361,46 +360,46 @@ admin.get('/get_namespace_by_type_for_jenkins/:_type', async function (req, res)
// 给jenkins使用获取服务groupname_projectname // 给jenkins使用获取服务groupname_projectname
admin.get('/get_groupname_by_type_for_jenkins/:_type', async function (req, res) { admin.get('/get_groupname_by_type_for_jenkins/:_type', async function (req, res) {
let configs = await getProjectConfigPromiseByDb(); let configs = await getProjectConfigPromiseByDb();
let re = { let re = {
ui:[], ui: [],
java:[], java: [],
node:[], node: [],
python:[] python: []
}; };
let xjdui = [["",""],["",""]],payui=[["",""],["",""]] let xjdui = [["", ""], ["", ""]], payui = [["", ""], ["", ""]]
for(let o of configs){ for (let o of configs) {
if(o.project_name == "xyqb-ui"){ if (o.project_name == "xyqb-ui") {
xjdui[0][0] = o.git_path_group xjdui[0][0] = o.git_path_group
xjdui[1][0] = o.project_name xjdui[1][0] = o.project_name
}else if(o.project_name == "paycenter-ui"){ } else if (o.project_name == "paycenter-ui") {
payui[0][0] = o.git_path_group payui[0][0] = o.git_path_group
payui[1][0] = o.project_name payui[1][0] = o.project_name
}else if(o.project_name == "xjd-ui"){ } else if (o.project_name == "xjd-ui") {
xjdui[0][1] = o.git_path_group xjdui[0][1] = o.git_path_group
xjdui[1][1] = o.project_name xjdui[1][1] = o.project_name
}else if(o.project_name == "new-paycenter-ui" ){ } else if (o.project_name == "new-paycenter-ui") {
payui[0][1] = o.git_path_group payui[0][1] = o.git_path_group
payui[1][1] = o.project_name payui[1][1] = o.project_name
}else{ } else {
if(req.params._type!="lua_ui"){ if (req.params._type != "lua_ui") {
if(re[req.params._type] == undefined){ if (re[req.params._type] == undefined) {
re[req.params._type] = []; re[req.params._type] = [];
} }
re[o.type].push(`${o.git_path_group}/${o.project_name}`) re[o.type].push(`${o.git_path_group}/${o.project_name}`)
} }
} }
} }
function getLuaUiStr(item){ function getLuaUiStr(item) {
return `${item[0][0]}--${item[0][1]}/${item[1][0]}--${item[1][1]}` return `${item[0][0]}--${item[0][1]}/${item[1][0]}--${item[1][1]}`
} }
let lua_ui = [],cb = ""; let lua_ui = [], cb = "";
if(req.params._type == "lua_ui"){ if (req.params._type == "lua_ui") {
lua_ui.push(getLuaUiStr(xjdui)); lua_ui.push(getLuaUiStr(xjdui));
lua_ui.push(getLuaUiStr(payui)); lua_ui.push(getLuaUiStr(payui));
cb = lua_ui.join("\n"); cb = lua_ui.join("\n");
}else{ } else {
res.send(re[req.params._type].join("\n")); res.send(re[req.params._type].join("\n"));
} }
}); });
// 增加一个新的nginx映射 // 增加一个新的nginx映射
......
var request = require('request'); var request = require('request');
function requestPromise (option) { function requestPromise(option) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
request(option, function (err, res, body) { request(option, function (err, res, body) {
if (err) { if (err) {
reject(err) reject(err)
} else { } else {
resolve(body) resolve(body)
} }
}) })
}) })
} }
var getattr = function (pro) { var getattr = function (pro) {
this.url = `http://192.168.4.3:10088/config_server/get_project_attr/${pro}`; this.url = `http://192.168.4.3:10088/config_server/get_project_attr/${pro}`;
this.method = "GET" this.method = "GET"
} }
var getpros = function () { var getpros = function () {
this.url = `http://192.168.4.3:10088/config_server/get_systems_by_type_for_temp`; this.url = `http://192.168.4.3:10088/config_server/get_systems_by_type_for_temp`;
this.method = "GET" this.method = "GET"
} }
let save_pod = function(body){ let save_pod = function (body) {
this.url = `http://192.168.28.170:3002/proconfig/server/save`; this.url = `http://192.168.28.170:3002/proconfig/server/save`;
this.method = "POST" this.method = "POST"
this.body = body; this.body = body;
this.json = true; this.json = true;
} }
function dosomething(ty,rs){ function dosomething(ty, rs) {
for(let i of rs){ for (let i of rs) {
console.log(i) console.log(i)
let _arrt_o = new getattr(i) let _arrt_o = new getattr(i)
requestPromise(_arrt_o).then(res=>{ requestPromise(_arrt_o).then(res => {
let attr = JSON.parse(res); let attr = JSON.parse(res);
let body = let body =
{ {
port: attr.port, port: attr.port,
is_active: true, is_active: true,
type: ty, type: ty,
git_path: attr.gitPath, git_path: attr.gitPath,
host_name: attr.host, host_name: attr.host,
log_path: attr.logName, log_path: attr.logName,
config_path: attr.configPath, config_path: attr.configPath,
des: attr.projectDesc, des: attr.projectDesc,
auth: attr.auth, auth: attr.auth,
jar_path: "", jar_path: "",
command1: "", command1: "",
command2: "", command2: "",
command3: "", command3: "",
command4: "", command4: "",
command5: "", command5: "",
build_command: "", build_command: "",
start_command: "", start_command: "",
stop_command: "" stop_command: ""
}
// "port": attr.port,
// "is_active": true,
// "type": ty,
// "port":attr.port,
// "full_name": attr.projectDesc,
// "git_path": attr.gitPath,
// "host_name": attr.host,
// "log_path": attr.logName,
// "config_path": attr.configPath,
// "des": attr.projectDesc,
// "auth": attr.auth,
// "jar_path": "",
// "command1": "",
// "command2": "",
// "command3": "",
// "command4": "",
// "command5": "",
// "build_command": "",
// "start_command": "",
// "stop_command": ""}
if (ty == "java") {
body.jar_path = attr.jarFilePath;
body.command1 = attr.node_version;
body.build_command = attr.buildCmd;
body.start_command = attr.command2;
} else if (ty == "ui") {
body.build_command = attr.buildCmd;
} else if (ty == "node") {
body.start_command = attr.buildCmd;
body.stop_command = attr.command2;
} else if (ty == "python") {
} }
// "port": attr.port,
// "is_active": true, let save_pod_o = new save_pod(
// "type": ty, body
// "port":attr.port, )
// "full_name": attr.projectDesc, console.log(body)
// "git_path": attr.gitPath, requestPromise(save_pod_o)
// "host_name": attr.host,
// "log_path": attr.logName,
// "config_path": attr.configPath,
// "des": attr.projectDesc,
// "auth": attr.auth,
// "jar_path": "",
// "command1": "",
// "command2": "",
// "command3": "",
// "command4": "",
// "command5": "",
// "build_command": "",
// "start_command": "",
// "stop_command": ""}
if(ty == "java"){
body.jar_path = attr.jarFilePath;
body.command1 = attr.node_version;
body.build_command = attr.command2;
body.start_command = attr.buildCmd;
}else if(ty == "ui"){
body.build_command = attr.buildCmd;
}else if(ty == "node"){
body.start_command = attr.buildCmd;
body.stop_command = attr.command2;
}else if(ty == "python"){
}
let save_pod_o = new save_pod(
body
)
console.log(body)
requestPromise(save_pod_o)
}); });
} }
} }
function main(){ function main() {
let _o = new getpros(); let _o = new getpros();
console.log("-----") console.log("-----")
requestPromise(_o).then(res=>{ requestPromise(_o).then(res => {
// console.log(res) // console.log(res)
let rr = JSON.parse(res); let rr = JSON.parse(res);
let ks = Object.keys(rr); let ks = Object.keys(rr);
console.log(ks) console.log(ks)
for(let i of ks){ for (let i of ks) {
dosomething(i,rr[i]) dosomething(i, rr[i])
} }
}); });
} }
main() main()
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