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
faf42d58
Commit
faf42d58
authored
Jan 22, 2018
by
tywldx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
6bc518f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
56 deletions
+61
-56
get_project_config_server.js
qa_shell_script/config_server/get_project_config_server.js
+61
-56
No files found.
qa_shell_script/config_server/get_project_config_server.js
View file @
faf42d58
...
@@ -30,6 +30,8 @@ var attrComsArr = [];
...
@@ -30,6 +30,8 @@ var attrComsArr = [];
for
(
let
i
of
attrComs
){
for
(
let
i
of
attrComs
){
attrComsArr
.
push
(
attrs
[
i
]);
attrComsArr
.
push
(
attrs
[
i
]);
}
}
// 获取节点命令
admin
.
get
(
'
/get_node_command/:name
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_node_command/:name
'
,
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`
)
var
str
=
execSync
(
`node ./get_project_config.js -name
${
req
.
params
.
name
}
-attr config_file/command/gitPathHead`
)
...
@@ -40,6 +42,8 @@ admin.get('/get_node_command/:name', function (req, res) {
...
@@ -40,6 +42,8 @@ admin.get('/get_node_command/:name', function (req, res) {
res
.
send
({
configPath
:
config_file
,
buildCmd
:
command
,
gitGroup
:
gitGroup
});
res
.
send
({
configPath
:
config_file
,
buildCmd
:
command
,
gitGroup
:
gitGroup
});
});
});
// 获取项目配置
admin
.
get
(
'
/get_project_attr/:name
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_project_attr/:name
'
,
function
(
req
,
res
)
{
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
var
comstr
=
attrComsArr
.
join
(
"
/
"
);
var
comstr
=
attrComsArr
.
join
(
"
/
"
);
...
@@ -60,6 +64,8 @@ admin.get('/get_project_attr/:name', function (req, res) {
...
@@ -60,6 +64,8 @@ admin.get('/get_project_attr/:name', function (req, res) {
res
.
send
(
rs
);
res
.
send
(
rs
);
});
});
// 获取所有域名
admin
.
get
(
'
/get_hosts
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_hosts
'
,
function
(
req
,
res
)
{
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
var
comstr
=
attrComsArr
.
join
(
"
/
"
);
var
comstr
=
attrComsArr
.
join
(
"
/
"
);
...
@@ -68,75 +74,74 @@ admin.get('/get_hosts', function (req, res) {
...
@@ -68,75 +74,74 @@ admin.get('/get_hosts', function (req, res) {
res
.
send
(
items
);
res
.
send
(
items
);
});
});
function
parseStr2Json
(
str
){
var
a
=
{};
var
strs
=
str
.
split
(
"
"
);
for
(
let
i
of
strs
){
if
(
i
){
let
os
=
i
.
split
(
"
|
"
);
a
[
os
[
0
]]
=
{
name
:
os
[
0
],
ip
:
os
[
1
],
http
:
os
[
2
],
https
:
os
[
3
]
}
}
}
return
a
}
function
parseJson2Str
(
json
){
var
a
=
[];
let
keys
=
Object
.
keys
(
json
);
for
(
let
k
of
keys
){
a
.
push
([
json
[
k
].
name
,
json
[
k
].
ip
,
json
[
k
].
http
,
json
[
k
].
https
].
join
(
"
|
"
))
}
return
a
.
join
(
"
"
)
}
// 增加一个新的nginx映射
admin
.
post
(
'
/add_new_proxy
'
,
function
(
req
,
res
)
{
admin
.
post
(
'
/add_new_proxy
'
,
function
(
req
,
res
)
{
let
request
=
req
.
body
;
let
request
=
req
.
body
;
let
new_namespace
=
request
[
"
namespace
"
],
new_ip
=
request
[
"
ip
"
],
new_ports
=
request
[
"
proxy_ports
"
];
var
str
=
String
(
execSync
(
`cat ../ngrok/docker_env_name.sh`
)).
replace
(
/
\n
/
,
""
);
var
str
=
String
(
execSync
(
`cat ../ngrok/docker_env_name.sh`
)).
replace
(
/
\n
/
,
""
);
console
.
log
(
str
)
let
data
=
parseStr2Json
(
str
);
var
index
=
str
.
indexOf
(
request
[
"
namespace
"
])
data
[
new_namespace
]
=
{
console
.
log
(
index
)
name
:
new_namespace
,
let
newstr
=
""
,
sourcestr
;
ip
:
new_ip
,
if
(
index
!=
-
1
){
http
:
new_ports
.
http_port
,
//存在这个配置,判断是否是原有的IP
https
:
new_ports
.
https_port
var
reg
=
new
RegExp
(
request
[
"
namespace
"
]
+
"
\\
|
\\
d*
\\
.
\\
d*
\\
.
\\
d*
\\
.
\\
d*
\
S*
"
);
try
{
sourcestr
=
str
.
match
(
reg
);
sourcestr
=
sourcestr
[
0
]
}
catch
(
e
){
res
.
send
({
msg
:
"
错误,请检查 docket_env_name.sh 文件
"
})
return
}
// proxy_ports = {
// "http_port": http_port,
// "https_port": https_port
// }
console
.
log
(
request
)
if
(
sourcestr
!=
undefined
){
var
items
=
sourcestr
.
split
(
"
|
"
);
if
(
items
[
1
]
==
request
[
"
ip
"
]){
res
.
send
({
msg
:
"
已经存在的配置
"
});
return
}
else
{
console
.
log
(
"
update new
"
)
targetstr
=
request
[
"
namespace
"
]
+
"
|
"
+
request
[
"
ip
"
]
+
"
|
"
+
request
[
"
proxy_ports
"
][
"
http_port
"
]
+
"
|
"
+
request
[
"
proxy_ports
"
][
"
https_port
"
]
+
"
"
;
newstr
=
str
.
replace
(
sourcestr
,
targetstr
);
}
}
else
{
res
.
send
({
msg
:
"
错误1
"
})
return
}
}
else
{
console
.
log
(
"
add new
"
)
newstr
=
str
+
"
"
+
request
[
"
namespace
"
]
+
"
|
"
+
request
[
"
ip
"
]
+
"
|
"
+
request
[
"
proxy_ports
"
][
"
http_port
"
]
+
"
|
"
+
request
[
"
proxy_ports
"
][
"
https_port
"
]
+
"
"
;
//文件添加到这里面
}
}
newstr
=
newstr
.
replace
(
/
\n
/
,
""
);
console
.
log
(
newstr
)
let
s
=
parseJson2Str
(
data
)
execSync
(
`echo "
${
newstr
}
" > ../ngrok/docker_env_name.sh`
)
s
=
s
.
replace
(
"
\n
"
,
""
)
execSync
(
`echo "
${
s
}
" > ../ngrok/docker_env_name.sh`
)
cproc
.
exec
(
"
../ngrok/make_frp_ini_V2.sh
"
);
cproc
.
exec
(
"
../ngrok/make_frp_ini_V2.sh
"
);
res
.
send
({
msg
:
"
执行完成
"
});
res
.
send
({
msg
:
"
执行完成
"
});
});
});
// 删除一个namespace映射
admin
.
post
(
'
/remove_proxy
'
,
function
(
req
,
res
)
{
admin
.
post
(
'
/remove_proxy
'
,
function
(
req
,
res
)
{
let
request
=
req
.
body
;
let
request
=
req
.
body
;
let
new_namespace
=
request
[
"
namespace
"
];
var
str
=
String
(
execSync
(
`cat ../ngrok/docker_env_name.sh`
)).
replace
(
/
\n
/
,
""
);
var
str
=
String
(
execSync
(
`cat ../ngrok/docker_env_name.sh`
)).
replace
(
/
\n
/
,
""
);
var
sourcestr
;
let
data
=
parseStr2Json
(
str
);
var
reg
=
new
RegExp
(
request
[
"
namespace
"
]
+
"
\\
|
\\
d*
\\
.
\\
d*
\\
.
\\
d*
\\
.
\\
d*
\
S*
"
);
delete
data
[
new_namespace
]
try
{
let
s
=
parseJson2Str
(
data
)
sourcestr
=
str
.
replace
(
reg
,
""
);
s
=
s
.
replace
(
"
\n
"
,
""
)
}
catch
(
e
){
execSync
(
`echo "
${
s
}
" > ../ngrok/docker_env_name.sh`
)
res
.
send
({
msg
:
"
错误,请检查 docket_env_name.sh 文件
"
})
cproc
.
exec
(
"
../ngrok/make_frp_ini_V2.sh
"
);
return
res
.
send
({
msg
:
"
执行完成
"
});
}
execSync
(
`echo "
${
sourcestr
}
" > ../ngrok/docker_env_name.sh`
);
cproc
.
exec
(
`../ngrok/remove.sh
${
request
[
"
namespace
"
]}
`
);
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
var
str
=
execSync
(
`cat ../ngrok/docker_env_name.sh`
)
res
.
send
({
namespace
:
String
(
str
)});
});
});
// 获取现有映射关系
admin
.
get
(
'
/get_proxy
'
,
function
(
req
,
res
)
{
admin
.
get
(
'
/get_proxy
'
,
function
(
req
,
res
)
{
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
res
.
setHeader
(
"
Content-Type
"
,
"
application/json
"
);
var
str
=
execSync
(
`cat ../ngrok/docker_env_name.sh`
)
var
str
=
execSync
(
`cat ../ngrok/docker_env_name.sh`
)
...
...
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