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)
...@@ -134,7 +133,7 @@ function getProjectConfigPromise() { ...@@ -134,7 +133,7 @@ function getProjectConfigPromise() {
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") {
} }
...@@ -362,43 +361,43 @@ admin.get('/get_namespace_by_type_for_jenkins/:_type', async function (req, res) ...@@ -362,43 +361,43 @@ admin.get('/get_namespace_by_type_for_jenkins/:_type', async function (req, res)
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"));
} }
}); });
......
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) {
...@@ -22,7 +22,7 @@ var getpros = function () { ...@@ -22,7 +22,7 @@ var getpros = function () {
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;
...@@ -30,11 +30,11 @@ let save_pod = function(body){ ...@@ -30,11 +30,11 @@ let save_pod = function(body){
} }
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 =
{ {
...@@ -59,36 +59,36 @@ function dosomething(ty,rs){ ...@@ -59,36 +59,36 @@ function dosomething(ty,rs){
stop_command: "" stop_command: ""
} }
// "port": attr.port, // "port": attr.port,
// "is_active": true, // "is_active": true,
// "type": ty, // "type": ty,
// "port":attr.port, // "port":attr.port,
// "full_name": attr.projectDesc, // "full_name": attr.projectDesc,
// "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": ""}
if(ty == "java"){ if (ty == "java") {
body.jar_path = attr.jarFilePath; body.jar_path = attr.jarFilePath;
body.command1 = attr.node_version; body.command1 = attr.node_version;
body.build_command = attr.command2;
body.start_command = attr.buildCmd;
}else if(ty == "ui"){
body.build_command = attr.buildCmd; body.build_command = attr.buildCmd;
}else if(ty == "node"){ body.start_command = attr.command2;
} else if (ty == "ui") {
body.build_command = attr.buildCmd;
} else if (ty == "node") {
body.start_command = attr.buildCmd; body.start_command = attr.buildCmd;
body.stop_command = attr.command2; body.stop_command = attr.command2;
}else if(ty == "python"){ } else if (ty == "python") {
} }
...@@ -106,22 +106,19 @@ function dosomething(ty,rs){ ...@@ -106,22 +106,19 @@ function dosomething(ty,rs){
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