Commit a400b68d authored by 智勇's avatar 智勇

fix

parent 01510169
......@@ -36,7 +36,6 @@ app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
var attrs = {
configPath: "config_file",
buildCmd: "command2",
gitPath: "git_path",
gitGroup: "gitPathHead",
host: "www",
......@@ -47,9 +46,9 @@ var attrs = {
jarFilePath: "target_path",
auth: "auth",
port: "port",
start_command: "",
stop_command: "",
command2: "command",
buildCmd: "command2",
startCmd: "command",
stopCmd: "stop_command",
node_version: "node_version"
}
var attrComs = Object.keys(attrs)
......@@ -134,7 +133,7 @@ function getProjectConfigPromise() {
temp.command2 = pro["build_command"];
} else if (pro["type"] == "node") {
temp.command = pro["start_command"]
temp.command2 = pro["stop_command"]
temp.stop_command = pro["stop_command"]
} else if (pro["type"] == "python") {
}
......@@ -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) {
let configs = await getProjectConfigPromiseByDb();
let re = {
ui:[],
java:[],
node:[],
python:[]
ui: [],
java: [],
node: [],
python: []
};
let xjdui = [["",""],["",""]],payui=[["",""],["",""]]
for(let o of configs){
if(o.project_name == "xyqb-ui"){
let xjdui = [["", ""], ["", ""]], payui = [["", ""], ["", ""]]
for (let o of configs) {
if (o.project_name == "xyqb-ui") {
xjdui[0][0] = o.git_path_group
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[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[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[1][1] = o.project_name
}else{
if(req.params._type!="lua_ui"){
if(re[req.params._type] == undefined){
} else {
if (req.params._type != "lua_ui") {
if (re[req.params._type] == undefined) {
re[req.params._type] = [];
}
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]}`
}
let lua_ui = [],cb = "";
if(req.params._type == "lua_ui"){
let lua_ui = [], cb = "";
if (req.params._type == "lua_ui") {
lua_ui.push(getLuaUiStr(xjdui));
lua_ui.push(getLuaUiStr(payui));
cb = lua_ui.join("\n");
}else{
} else {
res.send(re[req.params._type].join("\n"));
}
});
......
var request = require('request');
function requestPromise (option) {
function requestPromise(option) {
return new Promise(function (resolve, reject) {
request(option, function (err, res, body) {
if (err) {
......@@ -22,7 +22,7 @@ var getpros = function () {
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.method = "POST"
this.body = body;
......@@ -30,11 +30,11 @@ let save_pod = function(body){
}
function dosomething(ty,rs){
for(let i of rs){
function dosomething(ty, rs) {
for (let i of rs) {
console.log(i)
let _arrt_o = new getattr(i)
requestPromise(_arrt_o).then(res=>{
requestPromise(_arrt_o).then(res => {
let attr = JSON.parse(res);
let body =
{
......@@ -59,36 +59,36 @@ function dosomething(ty,rs){
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"){
// "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.command2;
body.start_command = attr.buildCmd;
}else if(ty == "ui"){
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.stop_command = attr.command2;
}else if(ty == "python"){
} else if (ty == "python") {
}
......@@ -106,22 +106,19 @@ function dosomething(ty,rs){
function main(){
function main() {
let _o = new getpros();
console.log("-----")
requestPromise(_o).then(res=>{
requestPromise(_o).then(res => {
// console.log(res)
let rr = JSON.parse(res);
let ks = Object.keys(rr);
console.log(ks)
for(let i of ks){
dosomething(i,rr[i])
for (let i of ks) {
dosomething(i, rr[i])
}
});
});
}
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