1. 重新初始化

2. 调整为手动更新,优化界面
3. 添加指定服务端口的环境变量
4. 修复获取个人数据返回值错误的bug
This commit is contained in:
ngfchl
2022-08-24 20:51:12 +08:00
parent 95ce774af2
commit 943304fe6e
5 changed files with 63 additions and 4 deletions

View File

@@ -10,4 +10,5 @@ urlpatterns = [
path(r'test_notify', views.test_notify, name='test_notify'),
path(r'restart', views.restart_container, name='restart_container'),
path(r'do_restart', views.do_restart, name='do_restart'),
path(r'do_update', views.do_update, name='do_update'),
]

View File

@@ -84,7 +84,8 @@ def do_restart(request):
try:
print('重启')
# print(os.system('pwd'))
subprocess.Popen('./update.sh')
subprocess.Popen('chmod +x ./update.sh')
subprocess.Popen('./restart.sh')
return JsonResponse(data=CommonResponse.success(
msg='重启指令发送成功!!'
).to_dict(), safe=False)
@@ -94,6 +95,23 @@ def do_restart(request):
).to_dict(), safe=False)
def do_update(request):
try:
print('更新')
# print(os.system('pwd'))
p = subprocess.Popen('chmod +x ./update.sh')
subprocess.Popen('./update.sh')
p.wait()
return JsonResponse(data=CommonResponse.success(
msg='更新成功!!'
).to_dict(), safe=False)
except Exception as e:
return JsonResponse(data=CommonResponse.error(
msg='更新指令发送失败!' + str(e)
).to_dict(), safe=False)
def restart_container(request):
scraper = pt_spider.get_scraper()
res = scraper.get('https://gitee.com/ngfchl/ptools/raw/master/update.md')

1
restart.sh Normal file
View File

@@ -0,0 +1 @@
docker restart $CONTAINER_NAME

View File

@@ -10,7 +10,8 @@
<div slot="header" class="clearfix">
<span>更新日志</span>
<span style="float: right;margin-top: -10px">
<el-button type="danger" @click="do_restart">重启更新</el-button>
<el-button type="success" @click="do_update">拉取更新</el-button>
<el-button type="danger" @click="do_restart">重启</el-button>
</span>
</div>
<div class="text item">
@@ -69,6 +70,44 @@
});
})
}).catch(res => {
console.log(res)
this.$message({
type: 'info',
message: '已取消重启'
});
});
},
do_update() {
this.$confirm('此操作会拉取软件更新软件,新版本不一定稳定,是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
axios.get(
"{% url "do_update" %}"
{#url + '/task/do_restart'#}
).then(res => {
if (res.data.code === 0) {
this.$message({
type: 'success',
message: res.data.msg
});
} else {
console.log(res)
this.$message({
type: 'warning',
message: res.data.msg
});
}
}).catch(res => {
this.$message({
type: 'error',
message: "更新失败!"
});
})
}).catch(res => {
console.log(res)
this.$message({

View File

@@ -1,5 +1,5 @@
git pull https://gitee.com/ngfchl/ptools &&
python manage.py makemigrations &&
python manage.py migrate &&
python manage.py loaddata db/pt.json &&
docker restart $CONTAINER_NAME
python manage.py loaddata db/pt.json