Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
deploy
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
deploy
Commits
6c43eba3
Commit
6c43eba3
authored
Oct 30, 2019
by
金凯强
🎨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
脚本修改
parent
d2a9157d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
5 deletions
+60
-5
load.sh
upgradeImage/load.sh
+5
-0
load_handle.py
upgradeImage/load_handle.py
+45
-0
upgrade_handle.py
upgradeImage/upgrade_handle.py
+10
-5
No files found.
upgradeImage/load.sh
0 → 100644
View file @
6c43eba3
#!/usr/bin/env bash
now_time
=
`
date
+%Y%m%d_%H%M%S
`
python
-u
load_handle.py
>
${
now_time
}
.log
\ No newline at end of file
upgradeImage/load_handle.py
0 → 100644
View file @
6c43eba3
# -*- coding:utf-8 -*-
import
os
import
re
if
__name__
==
'__main__'
:
with
os
.
popen
(
'ls | grep .tar'
)
as
f
:
cmd_txt
=
f
.
read
()
if
not
cmd_txt
:
raise
RuntimeError
(
'请检查文件,tar文件为空'
)
app_name_list
=
cmd_txt
.
split
(
'
\n
'
)
for
app_name
in
app_name_list
:
if
not
app_name
:
continue
print
(
'加载镜像:{}'
.
format
(
app_name
[:
-
4
]
.
replace
(
'___'
,
"/"
)
.
replace
(
"__"
,
":"
)))
cmd_res
=
os
.
system
(
'docker load -i {}'
.
format
(
app_name
))
if
cmd_res
==
1
:
raise
RuntimeError
(
'加载失败'
)
print
(
'镜像加载完毕'
)
print
(
'开始升级程序'
)
with
open
(
'docker-compose.yml'
,
'r'
)
as
f
:
compose_content
=
f
.
read
()
app_list_str
=
re
.
findall
(
'# app_list: ".*"'
,
compose_content
)
if
app_list_str
:
app_list_str
=
app_list_str
[
0
]
else
:
raise
RuntimeError
(
'未设置app_list'
)
app_str
=
app_list_str
[
len
(
'# app_list: "'
):
-
1
]
if
app_str
==
'*'
:
res
=
os
.
system
(
'''export HUANSI_REGISTRY_URL=47.110.145.204:8084 &&
\
source /etc/profile.d/huansi.sh &&
\
docker-compose up -d --force-recreate'''
)
else
:
res
=
os
.
system
(
'''export HUANSI_REGISTRY_URL=47.110.145.204:8084 &&
\
source /etc/profile.d/huansi.sh &&
\
docker-compose up -d --force-recreate --no-deps {}'''
.
format
(
app_str
))
if
res
==
1
:
raise
RuntimeError
(
'程序升级失败'
)
upgradeImage/upgrade_handle.py
View file @
6c43eba3
...
...
@@ -14,11 +14,16 @@ if __name__ == "__main__":
log
.
info
(
'开始打包镜像'
)
image_instance
.
save_images
()
log
.
info
(
'复制docker-compose.yml文件到/data/upgrade下'
)
ShellManage
()
.
exec_shell
(
'cp -f ./docker-compose.yml /data/upgrade/docker-compose.yml'
)
ShellManage
()
.
exec_shell
(
'cp -f /huansi/gitlab-runner/builds/analysis_file_to_hsright.py /data/upgrade/docker-compose.yml/analysis_file_to_hsright.py'
)
ShellManage
()
.
exec_shell
(
'cp -f /huansi/gitlab-runner/builds/analysis_file_to_nginx.py /data/upgrade/docker-compose.yml/analysis_file_to_nginx.py'
)
ShellManage
()
.
exec_shell
(
'cp -f /huansi/gitlab-runner/builds/base_util.py /data/upgrade/docker-compose.yml/base_util.py'
)
ShellManage
()
.
exec_shell
(
'cp -f /huansi/gitlab-runner/builds/app.conf /data/upgrade/docker-compose.yml/app.conf'
)
ShellManage
()
.
exec_shell
(
'cp -f /huansi/gitlab-runner/builds/docker-compose.yml /data/upgrade/docker-compose.yml'
)
ShellManage
()
.
exec_shell
(
'cp -f /huansi/gitlab-runner/builds/analysis_file_to_hsright.py /data/upgrade/analysis_file_to_hsright.py'
)
ShellManage
()
.
exec_shell
(
'cp -f /huansi/gitlab-runner/builds/analysis_file_to_nginx.py /data/upgrade/analysis_file_to_nginx.py'
)
ShellManage
()
.
exec_shell
(
'cp -f /huansi/gitlab-runner/builds/base_util.py /data/upgrade/base_util.py'
)
ShellManage
()
.
exec_shell
(
'cp -f /huansi/gitlab-runner/builds/app.conf /data/upgrade/app.conf'
)
ShellManage
()
.
exec_shell
(
'cp -f ./load_handle.py /data/upgrade/load_handle.py'
)
ShellManage
()
.
exec_shell
(
'cp -f ./load.sh /data/upgrade/load.sh'
)
log
.
info
(
'*********************************打包结束*********************************'
)
# log.info('开始上传镜像和脚本文件')
# ssh = SSHConnection(host='localhost', port=1111, username='root', pwd='huansi.net')
...
...
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