Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
install.api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Script
install.api
Commits
5232a74f
Commit
5232a74f
authored
Apr 08, 2020
by
金凯强
🎨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
车间为空报错
nginx配置修改接口
parent
20d69347
Pipeline
#22266
failed with stage
in 11 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
4 deletions
+37
-4
conncetion_service.py
app/conncetion/conncetion_service.py
+2
-2
info_api.py
app/info/info_api.py
+11
-0
info_service.py
app/info/info_service.py
+24
-2
No files found.
app/conncetion/conncetion_service.py
View file @
5232a74f
...
...
@@ -215,7 +215,7 @@ values
id
=
json_data
.
get
(
'id'
)
project_no
=
json_data
.
get
(
'project_no'
)
work_shop_no
=
json_data
.
get
(
'work_shop_no'
,
''
)
work_shop_no
=
json_data
.
get
(
'work_shop_no'
,
''
)
.
strip
()
db_ip
=
json_data
.
get
(
'db_ip'
)
db_port
=
json_data
.
get
(
'db_port'
)
db_user
=
json_data
.
get
(
'db_user'
)
...
...
@@ -223,7 +223,7 @@ values
mes_db_name
=
json_data
.
get
(
'mes_db_name'
)
if
project_no
is
None
or
db_ip
is
None
or
db_port
is
None
or
\
db_user
is
None
or
db_password
is
None
or
mes_db_name
is
None
or
work_shop_no
is
None
:
db_user
is
None
or
db_password
is
None
or
mes_db_name
is
None
or
not
work_shop_no
:
raise
HSException
(
'以上参数全部必填'
)
project_no
=
project_no
.
strip
()
...
...
app/info/info_api.py
View file @
5232a74f
...
...
@@ -33,6 +33,17 @@ class InfoAPI(ApiController):
args
=
request
.
args
return
InfoService
()
.
get_upgrade_log
(
args
)
@
api
(
'nginx_conf'
)
def
post_nginx
(
self
):
'''
同步nginx配置文件
:return:
'''
json_data
=
request
.
get_json
()
nginx_conf
=
json_data
.
get
(
'data'
)
file_name
=
json_data
.
get
(
'file_name'
)
return
InfoService
()
.
sync_nginx
(
file_name
,
nginx_conf
)
@
api
(
'upgrade_log_dtl/<int:log_id>'
)
def
get_upgrade_log_dtl
(
self
,
log_id
):
'''
...
...
app/info/info_service.py
View file @
5232a74f
...
...
@@ -13,7 +13,7 @@ import docker
from
app.conncetion.conncetion_service
import
ConnectionService
from
app.utils.db_tools
import
db_driver
from
static_file
import
builds_dir
,
back_up_dir
from
static_file
import
builds_dir
,
back_up_dir
,
base_dir
# docker_client = docker.APIClient(base_url='tcp://localhost:2375')
docker_client
=
docker
.
APIClient
(
base_url
=
'unix:///var/run/docker.sock'
)
...
...
@@ -221,10 +221,32 @@ where A.log_id={log_id}'''
since_time
=
None
tail
=
'200'
logs
=
docker_client
.
logs
(
'test'
,
tail
=
tail
,
since
=
since_time
)
# todo 测试用的,以后改为install_api
logs
=
docker_client
.
logs
(
'test'
,
tail
=
tail
,
since
=
since_time
)
# todo 测试用的,以后改为install_api
if
isinstance
(
logs
,
bytes
):
logs
=
logs
.
decode
()
# 去除所有含有debug信息的日志
filtered_logs
=
re
.
sub
(
'(
\
[20.*-.*DEBUG.*
\\
n)'
,
''
,
logs
)
return
filtered_logs
def
sync_nginx
(
self
,
file_name
,
nginx_conf
):
'''
同步nginx的配置文件
:param nginx_conf:
:return:
'''
if
not
nginx_conf
:
return
base_folder_path
=
os
.
path
.
join
(
base_dir
,
'conf'
)
if
not
os
.
path
.
exists
(
base_folder_path
):
os
.
mkdir
(
os
.
path
.
join
(
base_dir
,
'conf'
))
folder_path
=
os
.
path
.
join
(
base_folder_path
,
'nginx'
)
if
not
os
.
path
.
exists
(
folder_path
):
os
.
mkdir
(
folder_path
)
file_path
=
os
.
path
.
join
(
folder_path
,
file_name
)
with
open
(
file_path
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
nginx_conf
)
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