mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
优化更新逻辑
This commit is contained in:
@@ -314,6 +314,9 @@ def update_page(request):
|
||||
# 获取docker对象
|
||||
client = docker.from_env()
|
||||
# 从内部获取容器id
|
||||
cid = ''
|
||||
delta = 0
|
||||
restart = 'false'
|
||||
for c in client.api.containers():
|
||||
if 'ngfchl/ptools' in c.get('Image'):
|
||||
cid = c.get('Id')
|
||||
@@ -379,6 +382,8 @@ def do_update(request):
|
||||
del site_rules['id']
|
||||
site_obj = Site.objects.update_or_create(defaults=site_rules, url=site_rules.get('url'))
|
||||
logger.info(site_obj[0].name + (' 规则新增成功!' if site_obj[1] else '规则更新成功!'))
|
||||
logger.info('更新完毕')
|
||||
"""
|
||||
logger.info('更新完毕,开始重启')
|
||||
cid = request.GET.get('cid')
|
||||
flag = (cid == '')
|
||||
@@ -390,6 +395,10 @@ def do_update(request):
|
||||
return JsonResponse(data=CommonResponse.error(
|
||||
msg='更新成功,重启指令发送成功,容器重启中 ...' if not flag else '更新成功,未映射docker路径请手动重启容器 ...'
|
||||
).to_dict(), safe=False)
|
||||
"""
|
||||
return JsonResponse(data=CommonResponse.error(
|
||||
msg='更新成功,刷新页面后享用!'
|
||||
).to_dict(), safe=False)
|
||||
except Exception as e:
|
||||
# raise
|
||||
return JsonResponse(data=CommonResponse.error(
|
||||
|
||||
@@ -9,33 +9,33 @@
|
||||
<div id="app">
|
||||
<el-card class="box-card">
|
||||
<div slot="header" class="clearfix">
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
title="友情提示"
|
||||
width="300"
|
||||
trigger="hover"
|
||||
content="更新之前会自动备份数据库,更新完毕后会自动重启容器!">
|
||||
<el-button slot="reference" type="danger" @click="do_update"
|
||||
v-if="update && restart"
|
||||
>重启更新
|
||||
</el-button>
|
||||
</el-popover>
|
||||
{# <el-popover#}
|
||||
{# placement="top-start"#}
|
||||
{# title="友情提示"#}
|
||||
{# width="300"#}
|
||||
{# trigger="hover"#}
|
||||
{# content="更新之前会自动备份数据库,更新完毕后会自动重启容器!">#}
|
||||
{# <el-button slot="reference" type="danger" @click="do_update"#}
|
||||
{# v-if="update && restart"#}
|
||||
{# >重启更新#}
|
||||
{# </el-button>#}
|
||||
{# </el-popover>#}
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
title="友情提示"
|
||||
width="300"
|
||||
trigger="hover"
|
||||
content="没啥特殊功能,就是重启下容器!">
|
||||
<el-button slot="reference" type="danger" @click="do_restart" v-if="!update && restart">重启</el-button>
|
||||
<el-button slot="reference" type="danger" @click="do_restart" v-if="restart">重启</el-button>
|
||||
</el-popover>
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
title="友情提示"
|
||||
width="300"
|
||||
trigger="hover"
|
||||
content="未映射docker路径,更新完毕后请手动重启容器!">
|
||||
content="如果更新后更新功能未生效,请重启容器!!">
|
||||
<el-button slot="reference" type="danger" @click="do_update"
|
||||
v-if="update && !restart">更新
|
||||
v-if="update">更新
|
||||
</el-button>
|
||||
</el-popover>
|
||||
<el-popover
|
||||
@@ -142,12 +142,14 @@
|
||||
watch: {
|
||||
time: function (newValue) {
|
||||
if (newValue == 0) {
|
||||
this.$router.push("{% url "update_page" %}")
|
||||
location.reload()
|
||||
{#this.$route.replace("{% url "update_page" %}")#}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
timeDown() {
|
||||
console.log(this.time)
|
||||
this.time--
|
||||
},
|
||||
do_restart() {
|
||||
@@ -184,7 +186,7 @@
|
||||
},
|
||||
|
||||
do_update() {
|
||||
this.$confirm('此操作会拉取代码并更新软件,并重启容器,是否继续?', '提示', {
|
||||
this.$confirm('此操作会拉取代码并更新软件,是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
|
||||
Reference in New Issue
Block a user