Commit 9cae8bcb authored by 金凯强's avatar 金凯强 🎨

远程升级修改成异步处理

parent e984593d
Pipeline #21136 passed with stage
in 34 seconds
......@@ -33,7 +33,7 @@ class UpgradeAPI(ApiController):
return UpgradeService().remote_upgrade(log_id)
@api('remote/step1')
def get_remote_upgrade(self):
def get_remote_upgrade1(self):
'''
远程升级---1
:return:
......
# -*- coding:utf-8 -*-
import os
import re
from threading import Thread
from huansi_utils.app.apploader import logger
from huansi_utils.exception.exception import HSException
......@@ -108,12 +109,12 @@ docker-compose -f /data/upgrade_tools_data/backup/{upgrade_no}/docker-compose.ym
raise HSException(f'未找到{docker_compose_file_dir}')
return docker_compose_file_dir
def remote_upgrade(self, log_id=None):
'''
远程升级
:return:
'''
def _remote_upgrade(self, log_id):
from flask_app import global_app
with global_app.app_context():
from flask import g
g.user = {}
g.language = 'cn'
upgrade_no = self.get_upgrade_no_by_log_id(log_id)
self._package_images(upgrade_no)
......@@ -153,9 +154,20 @@ docker-compose -f /data/upgrade_tools_data/backup/{upgrade_no}/docker-compose.ym
out, err = ssh.exec_command("sh /huansi/upgrade/load.sh")
logger.info(f'远程升级信息:{out},远程错误信息:{out}')
logger.info(f'远程升级完成')
return {'message': '升级完成', out: err}
def remote_upgrade(self, log_id=None):
'''
远程升级
:return:
'''
t = Thread(target=self._remote_upgrade, args=(log_id,))
t.start()
return {"message": "开始安装runner"}
def remote_upgrade_step1(self):
'''
远程升级
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment