mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
1. 重新初始化
2. 调整为手动更新,优化界面 3. 添加指定服务端口的环境变量 4. 修复获取个人数据返回值错误的bug
This commit is contained in:
@@ -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'),
|
||||
]
|
||||
|
||||
@@ -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
1
restart.sh
Normal file
@@ -0,0 +1 @@
|
||||
docker restart $CONTAINER_NAME
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user