diff --git a/auto_pt/views.py b/auto_pt/views.py index ab89481..587d26e 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -330,11 +330,9 @@ def update_page(request): branch = os.getenv('DEV') if os.getenv('DEV') else 'master' local_logs = get_git_log(branch) - - logger.info('本地代码日志{}'.format(local_logs)) + logger.info('本地代码日志{} \n'.format(local_logs)) update_notes = get_git_log('origin/' + branch) - - logger.info('远程代码日志{}'.format(update_notes)) + logger.info('远程代码日志{} \n'.format(update_notes)) if datetime.strptime( update_notes[0].get('date'), '%Y-%m-%d %H:%M:%S') > datetime.strptime( local_logs[0].get('date'), '%Y-%m-%d %H:%M:%S' @@ -390,7 +388,7 @@ def do_update(request): new_requirements_mtime = os.stat('requirements.txt').st_mtime if new_requirements_mtime > requirements_mtime: logger.info('更新环境依赖') - result.extend(exec_command(migrate_commands)) + result.extend(exec_command(requirements_commands)) new_pt_site_site = os.stat('pt_site_site.json').st_mtime logger.info('更新前文件最后修改时间') logger.info(pt_site_site_mtime) @@ -432,7 +430,7 @@ def do_restart(request): # 获取docker对象 # client = docker.from_env() # 从内部获取容器id - cid = socket.gethostname() + cid = request.GET.get('cid') # 获取容器对象 # container = client.containers.get(cid) # 重启容器 diff --git a/templates/auto_pt/update.html b/templates/auto_pt/update.html index a3d0dd8..f4863e2 100644 --- a/templates/auto_pt/update.html +++ b/templates/auto_pt/update.html @@ -187,8 +187,11 @@ type: 'warning' }).then(() => { axios.get( - "{% url "do_restart" %}" - ).then(res => { + "{% url "do_restart" %}", { + params: { + cid: this.cid + } + }).then(res => { if (res.data.code === 0) { this.$message({ type: 'success', @@ -220,11 +223,7 @@ type: 'warning' }).then(() => { axios.get( - "{% url "do_update" %}", { - params: { - cid: this.cid - } - } + "{% url "do_update" %}" ).then(res => { if (res.data.code === 0) { console.log(res, 1)