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
15af8ce5
Commit
15af8ce5
authored
Feb 24, 2018
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
适配
parent
4d49407e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
91 deletions
+51
-91
get_project_config_from_mongo.js
...ell_script/config_server/get_project_config_from_mongo.js
+7
-64
get_project_config_server.js
qa_shell_script/config_server/get_project_config_server.js
+44
-27
No files found.
qa_shell_script/config_server/get_project_config_from_mongo.js
View file @
15af8ce5
...
...
@@ -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
=
JSON
.
parse
(
projects
)
// console.log(typeof(projects))
// console.log(projects)
for
(
var
index
in
projects
)
{
// if (projects[index]['project_name'] == 'xyqb') {
// console.log(index)
// console.log(projects[index])
// }
switch
(
projects
[
index
][
'
type
'
])
{
case
"
java
"
:
java_projects
.
push
(
projects
[
index
]);
...
...
@@ -36,7 +31,7 @@ for (var index in projects) {
break
;
}
}
// console.log(111)
// // --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", "");
...
...
@@ -64,32 +59,9 @@ function getListAttr(projects, attr) {
}
var
configFunction
=
function
()
{};
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
)
{
for
(
var
index
in
projects
)
{
if
(
projects
[
index
][
'
project_
name
'
]
==
pName
)
{
if
(
projects
[
index
][
'
name
'
]
==
pName
)
{
var
attrs
=
pAttr
.
split
(
"
/
"
);
if
(
attrs
.
length
==
0
)
{
console
.
log
(
""
)
...
...
@@ -104,40 +76,11 @@ configFunction.prototype = {
}
}
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
)
{
var
attrs
=
attr
.
split
(
"
/
"
);
if
(
attrs
.
length
==
0
)
{
...
...
@@ -148,7 +91,7 @@ configFunction.prototype = {
if
(
attr2
==
"
true
"
)
{
for
(
var
i
=
0
;
i
<
projects
.
length
;
i
++
)
{
if
(
projects
[
i
].
url
!=
""
)
{
var
li
=
[
projects
[
i
][
"
project_
name
"
]];
var
li
=
[
projects
[
i
][
"
name
"
]];
for
(
var
j
=
0
;
j
<
attrs
.
length
;
j
++
)
{
li
.
push
(
projects
[
i
][
attrs
[
j
]]);
}
...
...
@@ -159,7 +102,7 @@ configFunction.prototype = {
}
else
{
for
(
var
i
=
0
;
i
<
projects
.
length
;
i
++
)
{
// if (projects[i].is_active){
var
li
=
[
projects
[
i
][
"
project_
name
"
]];
var
li
=
[
projects
[
i
][
"
name
"
]];
for
(
var
j
=
0
;
j
<
attrs
.
length
;
j
++
)
{
li
.
push
(
projects
[
i
][
attrs
[
j
]]);
}
...
...
qa_shell_script/config_server/get_project_config_server.js
View file @
15af8ce5
...
...
@@ -151,23 +151,23 @@ admin.get('/get_hosts', function(req, res) {
});
// 根据类型获取系统名称
admin
.
get
(
'
/get_systems_by_type
'
,
function
(
req
,
res
)
{
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
var
ui_str
=
execSync
(
`node ./get_project_config.js -type ui -attr name`
)
ui_str
=
String
(
ui_str
)
.
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
(
/
\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
({
common
:
"
db,redis,rabbitmq,zookeeper
"
,
frontend
:
ui_str
,
backend
:
server_str
});
admin
.
get
(
'
/get_systems_by_type
'
,
function
(
req
,
res
)
{
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
var
ui_str
=
execSync
(
`node ./get_project_config.js -type ui -attr name`
)
ui_str
=
String
(
ui_str
)
.
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
(
/
\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
({
common
:
"
db,redis,rabbitmq,zookeeper
"
,
frontend
:
ui_str
,
backend
:
server_str
});
});
// 给jenkins使用根据类型获取系统名称
...
...
@@ -268,17 +268,34 @@ admin.get('/get_project_config_from_db', function(req, res) {
let
proconfigs
=
db
.
collection
(
'
proconfigs
'
);
let
projects
=
await
proconfigs
.
find
().
toArray
();
let
re
=
[];
// for (var i = 0; i < projects.length; i++) {
// let project_name=projects[i]['project_name'];
// let temp = { project_name: projects[i] };
// // temp[projects[i]['project_name']] = projects[i];
// console.log(temp)
// re.push(temp);
// }
for
(
var
index
=
0
;
index
<
projects
.
length
;
index
++
)
{
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
"
],
// 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)
re
.
push
(
temp
);
}
db
.
close
();
res
.
send
(
projects
)
res
.
send
(
re
)
});
}
test
();
...
...
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