Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-deploy-utils
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qa-deploy-utils
Commits
94bbb4b1
Commit
94bbb4b1
authored
Feb 28, 2018
by
tywldx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
3c3428fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
319 additions
and
267 deletions
+319
-267
get_project_config.js
qa_shell_script/config_server/get_project_config.js
+171
-133
get_project_config_server.js
qa_shell_script/config_server/get_project_config_server.js
+148
-134
No files found.
qa_shell_script/config_server/get_project_config.js
View file @
94bbb4b1
var
cproc
=
require
(
'
child_process
'
);
const
mongoose
=
require
(
'
mongoose
'
);
var
execSync
=
cproc
.
execSync
;
var
project_name
,
project_attr
,
projects
=
{},
java_projects
=
[],
node_projects
=
[],
python_projects
=
[],
ui_projects
=
[];
var
param
=
{
type
:
""
,
name
:
""
,
attr
:
""
}
projects
=
{}
_projects
=
String
(
execSync
(
`curl -s http://192.168.4.3:10088/config_server/get_project_config_from_db`
))
_projects
=
JSON
.
parse
(
_projects
)
// console.log(typeof(projects))
for
(
let
pro
of
_projects
)
{
projects
[
pro
.
name
]
=
pro
;
switch
(
pro
[
'
type
'
])
{
case
"
java
"
:
java_projects
.
push
(
pro
);
break
;
case
"
node
"
:
node_projects
.
push
(
pro
);
break
;
case
"
ui
"
:
ui_projects
.
push
(
pro
);
break
;
case
"
python
"
:
python_projects
.
push
(
pro
);
break
;
}
}
var
temp
=
""
;
process
.
argv
.
forEach
(
function
(
val
,
index
,
array
)
{
if
(
index
>=
2
)
{
if
(
index
%
2
==
0
)
{
temp
=
val
.
replace
(
/
\-
/
,
""
);
param
[
temp
]
=
""
;
}
else
{
param
[
temp
]
=
val
;
}
}
});
function
getListAttr
(
projects
,
attr
)
{
function
getListAttr
(
projects
,
attr
)
{
var
list
=
[];
var
list
=
[];
for
(
var
i
=
0
;
i
<
projects
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
projects
.
length
;
i
++
)
{
// if (projects[i].is_active) {
list
.
push
(
projects
[
i
][
attr
])
list
.
push
(
projects
[
i
][
attr
])
// }
}
}
return
list
.
join
(
"
"
);
return
list
.
join
(
"
"
);
}
}
var
configFunction
=
function
()
{};
configFunction
.
prototype
=
{
function
getProjectAttr
(
projects
,
pName
,
pAttr
)
{
getProjectAttr
:
function
(
pName
,
pAttr
)
{
if
(
typeof
projects
[
pName
]
==
"
undefined
"
)
{
if
(
typeof
projects
[
pName
]
==
"
undefined
"
)
{
console
.
log
(
""
)
return
""
}
else
{
}
else
{
var
attrs
=
pAttr
.
split
(
"
/
"
);
var
attrs
=
pAttr
.
split
(
"
/
"
);
if
(
attrs
.
length
==
0
)
{
if
(
attrs
.
length
==
0
)
{
console
.
log
(
""
)
return
""
return
}
}
var
list
=
[];
var
list
=
[];
for
(
var
j
=
0
;
j
<
attrs
.
length
;
j
++
)
{
for
(
var
j
=
0
;
j
<
attrs
.
length
;
j
++
)
{
if
(
projects
[
pName
][
attrs
[
j
]]){
if
(
projects
[
pName
][
attrs
[
j
]]){
list
.
push
(
projects
[
pName
][
attrs
[
j
]].
split
(
"
"
).
join
(
"
^
"
));
list
.
push
(
projects
[
pName
][
attrs
[
j
]].
split
(
"
"
).
join
(
"
^
"
));
}
else
{
}
else
{
list
.
push
(
"
"
);
list
.
push
(
"
"
);
}
}
}
}
console
.
log
(
list
.
join
(
"
|
"
)
)
return
list
.
join
(
"
|
"
)
}
}
},
}
getProjectsAttrs
:
function
(
projects
,
attr
,
attr2
)
{
function
getProjectsAttrs
(
projects
,
attr
,
attr2
)
{
var
attrs
=
attr
.
split
(
"
/
"
);
var
attrs
=
attr
.
split
(
"
/
"
);
if
(
attrs
.
length
==
0
)
{
if
(
attrs
.
length
==
0
)
{
return
return
...
@@ -92,67 +43,154 @@ configFunction.prototype = {
...
@@ -92,67 +43,154 @@ configFunction.prototype = {
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
]]);
}
}
// li.push(projects[i].url);
list
.
push
(
li
.
join
(
"
|
"
));
list
.
push
(
li
.
join
(
"
|
"
));
}
}
}
}
}
else
{
}
else
{
for
(
var
i
=
0
;
i
<
projects
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
projects
.
length
;
i
++
)
{
// if (projects[i].is_active){
var
li
=
[
projects
[
i
][
"
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
]]);
}
}
list
.
push
(
li
.
join
(
"
|
"
));
list
.
push
(
li
.
join
(
"
|
"
));
// }
}
}
}
}
return
list
.
join
(
"
"
);
return
list
.
join
(
"
"
);
},
}
getProjectsAttr
:
function
(
type
,
attr
)
{
switch
(
type
)
{
function
db2db
(
pro
){
let
temp
=
{
project_group
:
""
,
name
:
pro
[
"
project_name
"
],
type
:
pro
[
"
type
"
],
url
:
pro
[
"
host_name
"
].
replace
(
"
.xyqb.com
"
,
""
).
replace
(
"
.quantgroup.cn
"
,
""
),
www
:
pro
[
"
host_name
"
],
git_path
:
pro
[
"
git_path
"
],
log_name
:
pro
[
"
log_path
"
],
config_file
:
pro
[
"
config_path
"
],
command
:
""
,
command_
:
""
,
command2
:
""
,
node_version
:
""
,
port
:
`
${
pro
[
"
port
"
]}
`
,
desc
:
pro
[
"
des
"
],
is_active
:
pro
[
"
is_active
"
],
auth
:
pro
[
"
auth
"
],
target_path
:
""
}
if
(
pro
[
"
type
"
]
==
"
java
"
){
temp
.
node_version
=
pro
[
"
command1
"
];
temp
.
target_path
=
pro
[
"
jar_path
"
];
temp
.
command2
=
pro
[
"
build_command
"
];
temp
.
command
=
pro
[
"
start_command
"
];
}
else
if
(
pro
[
"
type
"
]
==
"
ui
"
){
temp
.
command
=
pro
[
"
build_command
"
]
}
else
if
(
pro
[
"
type
"
]
==
"
node
"
){
temp
.
command
=
pro
[
"
start_command
"
]
temp
.
command2
=
pro
[
"
stop_command
"
]
}
else
if
(
pro
[
"
type
"
]
==
"
python
"
){
}
return
temp
}
function
controller
(
param
){
//链接数据库
mongoose
.
connect
(
'
mongodb://172.30.220.22:27017/qaHome
'
)
mongoose
.
model
(
"
ProConfig
"
,
new
mongoose
.
Schema
({})).
find
({}).
exec
().
then
(
res
=>
{
// 定义数据
let
_res
=
JSON
.
parse
(
JSON
.
stringify
(
res
));
var
project_name
,
project_attr
,
projects
=
{},
java_projects
=
[],
node_projects
=
[],
python_projects
=
[],
ui_projects
=
[]
hosts
=
{};
projects
=
{}
for
(
let
pro
of
_res
)
{
let
temp
=
db2db
(
pro
);
projects
[
temp
.
name
]
=
temp
;
hosts
[
temp
.
name
]
=
temp
.
www
;
switch
(
pro
[
'
type
'
])
{
case
"
java
"
:
case
"
java
"
:
console
.
log
(
getListAttr
(
java_projects
,
attr
));
java_projects
.
push
(
temp
);
break
;
case
"
node
"
:
node_projects
.
push
(
temp
);
break
;
break
;
case
"
ui
"
:
case
"
ui
"
:
console
.
log
(
getListAttr
(
ui_projects
,
attr
)
);
ui_projects
.
push
(
temp
);
break
;
break
;
case
"
python
"
:
case
"
python
"
:
console
.
log
(
getListAttr
(
python_projects
,
attr
));
python_projects
.
push
(
temp
);
break
;
case
"
node
"
:
console
.
log
(
getListAttr
(
node_projects
,
attr
));
break
;
break
;
}
}
}
}
}
//tower add
//定义方法
module
.
exports
=
{
java
:
java_projects
,
node
:
node_projects
,
python
:
python_projects
,
ui
:
ui_projects
}
var
F
=
new
configFunction
();
try
{
if
(
param
[
"
type
"
]
==
""
)
{
if
(
param
[
"
type
"
]
==
""
)
{
F
.
getProjectAttr
(
param
[
"
name
"
],
param
[
"
attr
"
]);
let
str
=
getProjectAttr
(
projects
,
param
[
"
name
"
],
param
[
"
attr
"
]);
console
.
log
(
str
);
}
else
if
(
param
[
"
type
"
]
==
"
multi
"
)
{
}
else
if
(
param
[
"
type
"
]
==
"
multi
"
)
{
var
str
=
""
;
var
str
=
""
;
str
+=
F
.
getProjectsAttrs
(
java_projects
,
param
[
"
attr
"
],
param
[
"
attr2
"
]);
str
+=
getProjectsAttrs
(
java_projects
,
param
[
"
attr
"
],
param
[
"
attr2
"
]);
str
+=
"
"
+
F
.
getProjectsAttrs
(
ui_projects
,
param
[
"
attr
"
],
param
[
"
attr2
"
]);
str
+=
"
"
+
getProjectsAttrs
(
ui_projects
,
param
[
"
attr
"
],
param
[
"
attr2
"
]);
str
+=
"
"
+
F
.
getProjectsAttrs
(
python_projects
,
param
[
"
attr
"
],
param
[
"
attr2
"
]);
str
+=
"
"
+
getProjectsAttrs
(
python_projects
,
param
[
"
attr
"
],
param
[
"
attr2
"
]);
str
+=
"
"
+
F
.
getProjectsAttrs
(
node_projects
,
param
[
"
attr
"
],
param
[
"
attr2
"
]);
str
+=
"
"
+
getProjectsAttrs
(
node_projects
,
param
[
"
attr
"
],
param
[
"
attr2
"
]);
console
.
log
(
str
)
console
.
log
(
str
)
}
else
if
(
param
[
"
type
"
]
==
"
hosts
"
)
{
}
else
if
(
param
[
"
type
"
]
==
"
hosts
"
)
{
console
.
log
(
JSON
.
stringify
(
hosts
));
console
.
log
(
JSON
.
stringify
(
hosts
));
}
else
{
}
else
{
F
.
getProjectsAttr
(
param
[
"
type
"
],
param
[
"
attr
"
]);
switch
(
param
[
"
type
"
])
{
case
"
java
"
:
console
.
log
(
getListAttr
(
java_projects
,
param
[
"
attr
"
]));
break
;
case
"
ui
"
:
console
.
log
(
getListAttr
(
ui_projects
,
param
[
"
attr
"
]));
break
;
case
"
python
"
:
console
.
log
(
getListAttr
(
python_projects
,
param
[
"
attr
"
]));
break
;
case
"
node
"
:
console
.
log
(
getListAttr
(
node_projects
,
param
[
"
attr
"
]));
break
;
}
}
//关闭连接
mongoose
.
connection
.
close
()
}).
catch
((
err
)
=>
{
//关闭链接
console
.
log
(
err
)
mongoose
.
connection
.
close
()
});
}
function
main
(){
var
param
=
{
type
:
""
,
name
:
""
,
attr
:
""
}
//获取请求参数
var
temp
=
""
;
process
.
argv
.
forEach
(
function
(
val
,
index
,
array
)
{
if
(
index
>=
2
)
{
if
(
index
%
2
==
0
)
{
temp
=
val
.
replace
(
/
\-
/
,
""
);
param
[
temp
]
=
""
;
}
else
{
param
[
temp
]
=
val
;
}
}
}
});
controller
(
param
)
//这里区分使用那个方法,需要注意的是,这里不在提供输出结果,结果在mongo链接中输出
}
try
{
main
()
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
""
)
console
.
log
(
""
)
}
}
\ No newline at end of file
qa_shell_script/config_server/get_project_config_server.js
View file @
94bbb4b1
...
@@ -2,7 +2,9 @@ var express = require('express');
...
@@ -2,7 +2,9 @@ var express = require('express');
var
cproc
=
require
(
'
child_process
'
);
var
cproc
=
require
(
'
child_process
'
);
var
bodyParser
=
require
(
'
body-parser
'
);
var
bodyParser
=
require
(
'
body-parser
'
);
var
db_config
=
require
(
'
./config/db
'
);
var
db_config
=
require
(
'
./config/db
'
);
const
mongodb
=
require
(
'
mongodb
'
);
// const mongodb = require('mongodb');
const
mongoose
=
require
(
'
mongoose
'
);
var
ProConfig
=
require
(
'
./model/proconfig.js
'
);
// return
// return
var
execSync
=
cproc
.
execSync
;
var
execSync
=
cproc
.
execSync
;
var
options
=
{
var
options
=
{
...
@@ -10,8 +12,10 @@ var options = {
...
@@ -10,8 +12,10 @@ var options = {
limit
:
'
100kb
'
,
limit
:
'
100kb
'
,
type
:
'
application/octet-stream
'
type
:
'
application/octet-stream
'
};
};
// const mongoose = require('mongoose');
// mongoose.connect('mongodb://localhost/my_database');
// mongoose.connect('mongodb://localhost/my_database');
mongoose
.
connect
(
'
mongodb://172.30.220.22:27017/qaHome
'
)
var
app
=
express
();
var
app
=
express
();
var
admin
=
express
();
// the sub app
var
admin
=
express
();
// the sub app
...
@@ -76,6 +80,65 @@ function parseJson2Str(json) {
...
@@ -76,6 +80,65 @@ function parseJson2Str(json) {
// DB 维护数据
// DB 维护数据
let
db_conf
=
db_config
.
db_config
();
let
db_conf
=
db_config
.
db_config
();
let
db_conf_keys
=
Object
.
keys
(
db_conf
);
let
db_conf_keys
=
Object
.
keys
(
db_conf
);
// 从mongo中获取配置
function
getProjectConfigPromise
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
// mongoose.model("ProConfig",new mongoose.Schema({}))
ProConfig
.
find
({}).
exec
().
then
(
res
=>
{
let
_pros
=
JSON
.
parse
(
JSON
.
stringify
(
res
));
let
re
=
{},
hosts
=
{};
for
(
let
pro
of
_pros
){
hosts
[
pro
[
"
project_name
"
]]
=
pro
[
"
host_name
"
];
if
(
pro
[
"
project_name
"
]
==
"
xjd-ui
"
){
hosts
[
"
xyqb-ui--xjd-ui
"
]
=
pro
[
"
host_name
"
];
}
else
if
(
pro
[
"
project_name
"
]
==
"
new-paycenter-ui
"
){
hosts
[
"
paycenter-ui--new-paycenter-ui
"
]
=
pro
[
"
host_name
"
];
}
let
temp
=
{
project_group
:
""
,
name
:
pro
[
"
project_name
"
],
type
:
pro
[
"
type
"
],
url
:
pro
[
"
host_name
"
].
replace
(
"
.xyqb.com
"
,
""
).
replace
(
"
.quantgroup.cn
"
,
""
),
www
:
pro
[
"
host_name
"
],
git_path
:
pro
[
"
git_path
"
],
log_name
:
pro
[
"
log_path
"
],
config_file
:
pro
[
"
config_path
"
],
command
:
""
,
command_
:
""
,
command2
:
""
,
node_version
:
""
,
port
:
`
${
pro
[
"
port
"
]}
`
,
desc
:
pro
[
"
des
"
],
is_active
:
pro
[
"
is_active
"
],
auth
:
pro
[
"
auth
"
],
target_path
:
""
}
if
(
pro
[
"
type
"
]
==
"
java
"
){
temp
.
node_version
=
pro
[
"
command1
"
];
temp
.
target_path
=
pro
[
"
jar_path
"
];
temp
.
command2
=
pro
[
"
build_command
"
];
temp
.
command
=
pro
[
"
start_command
"
];
}
else
if
(
pro
[
"
type
"
]
==
"
ui
"
){
temp
.
command
=
pro
[
"
build_command
"
]
}
else
if
(
pro
[
"
type
"
]
==
"
node
"
){
temp
.
command
=
pro
[
"
start_command
"
]
temp
.
command2
=
pro
[
"
stop_command
"
]
}
else
if
(
pro
[
"
type
"
]
==
"
python
"
){
}
re
[
temp
[
"
name
"
]]
=
temp
;
}
resolve
({
projects
:
re
,
hosts
:
hosts
})
}).
catch
((
err
)
=>
{
reject
(
err
)
});
})
}
//
//
admin
.
get
(
'
/get_db_config/:name/:attr
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_db_config/:name/:attr
'
,
function
(
req
,
res
)
{
let
str
=
""
let
str
=
""
...
@@ -92,6 +155,7 @@ admin.get('/get_db_config/:name/:attr', function(req, res) {
...
@@ -92,6 +155,7 @@ admin.get('/get_db_config/:name/:attr', function(req, res) {
}
}
}
}
});
});
admin
.
get
(
'
/get_db_dump_command/:name/:opt
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_db_dump_command/:name/:opt
'
,
function
(
req
,
res
)
{
if
(
req
.
params
.
opt
!=
"
opt
"
)
{
if
(
req
.
params
.
opt
!=
"
opt
"
)
{
res
.
send
(
db_config
.
get_mysql_dump_table
(
req
.
params
.
name
));
res
.
send
(
db_config
.
get_mysql_dump_table
(
req
.
params
.
name
));
...
@@ -108,21 +172,18 @@ admin.get('/get_db_config/refersh', function() {
...
@@ -108,21 +172,18 @@ admin.get('/get_db_config/refersh', function() {
// 获取节点命令
// 获取节点命令
admin
.
get
(
'
/get_node_command/:name
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_node_command/:name
'
,
async
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`
)
let
configs
=
await
getProjectConfigPromise
();
var
items
=
String
(
str
).
replace
(
/
\n
/g
,
""
).
split
(
"
|
"
);
let
projects
=
configs
.
projects
var
config_file
=
items
[
0
].
replace
(
/
\^
/g
,
"
"
);
let
pro
=
projects
[
req
.
params
.
name
];
var
command
=
items
[
1
].
replace
(
/
\^
/g
,
"
"
);
res
.
send
({
configPath
:
pro
.
config_file
,
buildCmd
:
pro
.
command
,
gitGroup
:
pro
.
gitPathHead
});
var
gitGroup
=
items
[
2
].
replace
(
/
\^
/g
,
"
"
);
res
.
send
({
configPath
:
config_file
,
buildCmd
:
command
,
gitGroup
:
gitGroup
});
});
});
// 获取项目配置
// 获取项目配置
admin
.
get
(
'
/get_project_attr/:name
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_project_attr/:name
'
,
async
function
(
req
,
res
)
{
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
var
comstr
=
attrComsArr
.
join
(
"
/
"
);
var
names
=
req
.
params
.
name
.
split
(
"
--
"
);
var
names
=
req
.
params
.
name
.
split
(
"
--
"
);
var
p_name
=
""
;
var
p_name
=
""
;
if
(
names
.
length
>
1
)
{
if
(
names
.
length
>
1
)
{
...
@@ -130,79 +191,99 @@ admin.get('/get_project_attr/:name', function(req, res) {
...
@@ -130,79 +191,99 @@ admin.get('/get_project_attr/:name', function(req, res) {
}
else
{
}
else
{
p_name
=
req
.
params
.
name
p_name
=
req
.
params
.
name
}
}
var
str
=
execSync
(
`node ./get_project_config.js -name
${
p_name
}
-attr
${
comstr
}
`
)
try
{
var
items
=
String
(
str
).
replace
(
/
\n
/g
,
""
).
split
(
"
|
"
);
let
configs
=
await
getProjectConfigPromise
(
);
let
rs
=
{},
let
projects
=
configs
.
projects
index
=
0
;
let
pro
=
projects
[
p_name
]
;
for
(
let
i
of
items
)
{
let
rs
=
{};
rs
[
attrComs
[
index
]]
=
i
.
replace
(
/
\^
/g
,
"
"
);
for
(
let
item
of
attrComs
){
index
++
rs
[
item
]
=
pro
[
attrs
[
item
]]
}
}
res
.
send
(
rs
);
res
.
send
(
rs
);
}
catch
(
e
){
console
.
log
(
e
)
res
.
send
(
e
)
}
});
});
// 获取所有域名
// 获取所有域名
admin
.
get
(
'
/get_hosts
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_hosts
'
,
async
function
(
req
,
res
)
{
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
var
str
=
execSync
(
`node ./get_project_config.js -type hosts`
)
let
configs
=
await
getProjectConfigPromise
();
var
items
=
String
(
str
);
res
.
send
(
configs
.
hosts
);
res
.
send
(
items
);
});
});
// 根据类型获取系统名称
// 根据类型获取系统名称
admin
.
get
(
'
/get_systems_by_type
'
,
function
(
req
,
res
)
{
function
getfrontendbackend
(
pros
){
let
temp
=
{
frontend
:
[],
backend
:
[],
ui
:[],
node
:[],
java
:[],
python
:[]
}
let
keys
=
Object
.
keys
(
pros
)
// console.log(keys)
for
(
let
key
of
keys
){
let
pro
=
pros
[
key
]
if
(
pro
.
type
==
"
ui
"
){
if
(
pro
.
name
!=
"
xyqb-ui
"
&&
pro
.
name
!=
"
paycenter-ui
"
){
if
(
pro
.
name
==
"
xjd-ui
"
){
temp
.
frontend
.
push
(
"
xyqb-ui--xjd-ui
"
);
temp
[
pro
.
type
].
push
(
"
xyqb-ui--xjd-ui
"
)
}
else
if
(
pro
.
name
==
"
new-paycenter-ui
"
){
temp
.
frontend
.
push
(
"
paycenter-ui--new-paycenter-ui
"
);
temp
[
pro
.
type
].
push
(
"
paycenter-ui--new-paycenter-ui
"
)
}
else
{
temp
.
frontend
.
push
(
pro
.
name
);
temp
[
pro
.
type
].
push
(
pro
.
name
)
}
}
}
else
{
temp
.
backend
.
push
(
pro
.
name
);
temp
[
pro
.
type
].
push
(
pro
.
name
)
}
}
return
temp
}
admin
.
get
(
'
/get_systems_by_type
'
,
async
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`
)
let
configs
=
await
getProjectConfigPromise
();
ui_str
=
String
(
ui_str
)
let
pros
=
configs
.
projects
;
.
replace
(
/xyqb-ui/g
,
""
).
replace
(
/xjd-ui/
,
"
xyqb-ui--xjd-ui
"
)
let
fb
=
getfrontendbackend
(
pros
);
.
replace
(
/new-paycenter-ui/g
,
""
).
replace
(
/paycenter-ui/
,
"
paycenter-ui--new-paycenter-ui
"
)
.
replace
(
/
\s
+/g
,
"
,
"
).
replace
(
/
\n
/g
,
""
).
slice
(
0
,
-
1
);
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
python_str
=
execSync
(
`node ./get_project_config.js -type python -attr name`
)
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
);;
res
.
send
({
res
.
send
({
common
:
"
db,redis,rabbitmq,zookeeper
"
,
common
:
"
db,redis,rabbitmq,zookeeper
"
,
frontend
:
ui_str
,
frontend
:
fb
.
frontend
.
join
(
"
"
)
,
backend
:
server_str
backend
:
fb
.
backend
.
join
(
"
"
)
});
});
});
});
// 给jenkins使用根据类型获取系统名称
// 给jenkins使用根据类型获取系统名称
admin
.
get
(
'
/get_systems_by_type_for_jenkins/:_type
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_systems_by_type_for_jenkins/:_type
'
,
async
function
(
req
,
res
)
{
let
str
=
""
let
str
=
""
;
if
(
req
.
params
.
_type
===
"
frontend
"
)
{
let
configs
=
await
getProjectConfigPromise
();
var
ui_str
=
execSync
(
`node ./get_project_config.js -type ui -attr name`
)
let
pros
=
configs
.
projects
;
str
=
String
(
ui_str
)
let
fb
=
getfrontendbackend
(
pros
);
.
replace
(
/xyqb-ui/g
,
""
).
replace
(
/xjd-ui/
,
"
xyqb-ui--xjd-ui
"
)
if
(
req
.
params
.
_type
===
"
frontend
"
){
.
replace
(
/new-paycenter-ui/g
,
""
).
replace
(
/paycenter-ui/
,
"
paycenter-ui--new-paycenter-ui
"
);
res
.
send
(
fb
.
frontend
.
join
(
"
"
));
}
else
{
}
else
{
var
java_str
=
execSync
(
`node ./get_project_config.js -type java -attr name`
)
res
.
send
(
fb
.
backend
.
join
(
"
"
));
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`
)
str
=
`
${
String
(
java_str
)}
${
String
(
node_str
)}
${
String
(
python_str
)}
`
}
}
str
=
str
.
replace
(
/
\n
/g
,
""
).
replace
(
/
\s
+/g
,
"
\n
"
);
res
.
send
(
str
);
});
});
// 给jenkins使用根据类型获取系统名称
// 给jenkins使用根据类型获取系统名称
admin
.
get
(
'
/get_systems_by_type_for_temp
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_systems_by_type_for_temp
'
,
async
function
(
req
,
res
)
{
var
ui_str
=
execSync
(
`node ./get_project_config.js -type ui -attr name`
)
let
configs
=
await
getProjectConfigPromise
();
ui_str
=
String
(
ui_str
).
split
(
/
\s
+/
)
let
pros
=
configs
.
projects
;
var
java_str
=
execSync
(
`node ./get_project_config.js -type java -attr name`
)
let
fb
=
getfrontendbackend
(
pros
);
java_str
=
String
(
java_str
).
split
(
/
\s
+/
)
var
node_str
=
execSync
(
`node ./get_project_config.js -type node -attr name`
)
node_str
=
String
(
node_str
).
split
(
/
\s
+/
)
var
python_str
=
execSync
(
`node ./get_project_config.js -type python -attr name`
)
python_str
=
String
(
python_str
).
split
(
/
\s
+/
)
res
.
send
({
res
.
send
({
ui
:
ui_str
,
ui
:
fb
.
ui
.
join
(
"
"
)
,
java
:
java_str
,
java
:
fb
.
java
.
join
(
"
"
)
,
node
:
node_str
,
node
:
fb
.
node
.
join
(
"
"
)
,
python
:
python_str
python
:
fb
.
python
.
join
(
"
"
)
});
});
});
});
...
@@ -260,74 +341,7 @@ admin.get('/get_proxy', function(req, res) {
...
@@ -260,74 +341,7 @@ admin.get('/get_proxy', function(req, res) {
});
});
// 从mongo中获取配置
admin
.
get
(
'
/get_project_config_from_db
'
,
function
(
req
,
res
)
{
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
async
function
test
()
{
let
db
=
await
mongodb
.
MongoClient
.
connect
(
'
mongodb://172.30.220.22:27017/qaHome
'
,
async
function
(
err
,
db
)
{
let
proconfigs
=
db
.
collection
(
'
proconfigs
'
);
let
projects
=
await
proconfigs
.
find
().
toArray
();
let
re
=
[];
for
(
var
index
=
0
;
index
<
projects
.
length
;
index
++
)
{
let
temp
=
{
project_group
:
""
,
name
:
projects
[
index
][
"
project_name
"
],
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
"
],
log_name
:
projects
[
index
][
"
log_path
"
],
config_file
:
projects
[
index
][
"
config_path
"
],
command
:
""
,
command_
:
""
,
command2
:
""
,
node_version
:
""
,
port
:
`
${
projects
[
index
][
"
port
"
]}
`
,
desc
:
projects
[
index
][
"
des
"
],
is_active
:
projects
[
index
][
"
is_active
"
],
auth
:
projects
[
index
][
"
auth
"
],
target_path
:
""
}
// let temp = {
// name: projects[index]["project_name"],
// 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"],
// 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"]
// }
if
(
projects
[
index
][
"
type
"
]
==
"
java
"
){
temp
.
node_version
=
projects
[
index
][
"
command1
"
];
temp
.
target_path
=
projects
[
index
][
"
jar_path
"
];
temp
.
command2
=
projects
[
index
][
"
build_command
"
];
temp
.
command
=
projects
[
index
][
"
start_command
"
];
}
else
if
(
projects
[
index
][
"
type
"
]
==
"
ui
"
){
temp
.
command
=
projects
[
index
][
"
build_command
"
]
}
else
if
(
projects
[
index
][
"
type
"
]
==
"
node
"
){
temp
.
command
=
projects
[
index
][
"
start_command
"
]
temp
.
command2
=
projects
[
index
][
"
stop_command
"
]
}
else
if
(
projects
[
index
][
"
type
"
]
==
"
python
"
){
}
re
.
push
(
temp
);
}
db
.
close
();
res
.
send
(
re
)
});
}
test
();
});
app
.
use
(
'
/config_server
'
,
admin
)
app
.
use
(
'
/config_server
'
,
admin
)
console
.
log
(
"
http://192.168.4.3:10088/config_server/get_node_command
"
)
console
.
log
(
"
http://192.168.4.3:10088/config_server/get_node_command
"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment