fix issue

pull/410/head
vapao 2021-08-30 18:17:57 +08:00
parent a2056edbbd
commit c0d7db81b5
8 changed files with 33 additions and 7 deletions

View File

@ -47,7 +47,7 @@ class DeployRequest(models.Model, ModelMixin):
@property
def is_quick_deploy(self):
if self.extra:
if self.deploy.extend == '1' and self.extra:
extra = json.loads(self.extra)
return extra[0] in ('branch', 'tag')
return False

View File

@ -181,7 +181,7 @@ def _deploy_ext1_host(req, helper, h_id, env):
try:
ssh.put_file(os.path.join(REPOS_DIR, 'build', tar_gz_file), os.path.join(extend.dst_repo, tar_gz_file))
except Exception as e:
helper.send_error(host.id, f'exception: {e}')
helper.send_error(host.id, f'Exception: {e}')
command = f'cd {extend.dst_repo} && rm -rf {req.spug_version} && tar xf {tar_gz_file} && rm -f {req.deploy_id}_*.tar.gz'
helper.remote_raw(host.id, ssh, command)
@ -222,7 +222,7 @@ def _deploy_ext2_host(helper, h_id, actions, env, spug_version):
try:
ssh.put_file(os.path.join(REPOS_DIR, env.SPUG_DEPLOY_ID, spug_version), action['dst'])
except Exception as e:
helper.send_error(host.id, f'exception: {e}')
helper.send_error(host.id, f'Exception: {e}')
helper.send_info(host.id, 'transfer completed\r\n')
continue
else:
@ -231,7 +231,7 @@ def _deploy_ext2_host(helper, h_id, actions, env, spug_version):
try:
ssh.put_file(os.path.join(sp_dir, tar_gz_file), f'/tmp/{tar_gz_file}')
except Exception as e:
helper.send_error(host.id, f'exception: {e}')
helper.send_error(host.id, f'Exception: {e}')
command = f'mkdir -p /tmp/{spug_version} && tar xf /tmp/{tar_gz_file} -C /tmp/{spug_version}/ '
command += f'&& rm -rf {action["dst"]} && mv /tmp/{spug_version}/{sd_dst} {action["dst"]} '

View File

@ -104,6 +104,6 @@ def _build(rep: Repository, helper, env):
exclude = ' '.join(excludes)
else:
contain = ' '.join(f'{rep.spug_version}/{x}' for x in files)
helper.local(f'cd {REPOS_DIR} && tar zcf {tar_file} {exclude} {contain}')
helper.local(f'mkdir -p {BUILD_DIR} && cd {REPOS_DIR} && tar zcf {tar_file} {exclude} {contain}')
helper.send_step('local', 5, f'\033[32m完成√\033[0m')
helper.send_step('local', 100, f'\r\n\r\n{human_time()} ** \033[32m构建成功\033[0m **')

View File

@ -55,6 +55,11 @@ export default observer(function Console() {
if (status !== undefined) setStatus(status);
}
}
socket.onerror = () => {
setStatus('error')
term.reset()
term.write('\u001b[31mWebsocket connection failed!\u001b[0m')
}
return socket
}

View File

@ -51,6 +51,7 @@ function ComTable() {
<Action.Button
auth="deploy.repository.build"
loading={loading === info.id}
disabled={info.remarks === 'SPUG AUTO MAKE'}
onClick={() => handleRebuild(info)}>构建</Action.Button>
<Action.Button auth="deploy.repository.build" onClick={() => store.showConsole(info)}>日志</Action.Button>
</Action>

View File

@ -63,6 +63,16 @@ function Ext1Console(props) {
if (status !== undefined) outputs[key].status = status;
}
}
socket.onerror = () => {
for (let key of Object.keys(outputs)) {
outputs[key]['status'] = 'error'
outputs[key].data = '\u001b[31mWebsocket connection failed!\u001b[0m'
if (terms[key]) {
terms[key].reset()
terms[key].write('\u001b[31mWebsocket connection failed!\u001b[0m')
}
}
}
return socket
}

View File

@ -68,6 +68,16 @@ function Ext2Console(props) {
if (status !== undefined) outputs[key].status = status;
}
}
socket.onerror = () => {
for (let key of Object.keys(outputs)) {
outputs[key]['status'] = 'error'
outputs[key].data = '\u001b[31mWebsocket connection failed!\u001b[0m'
if (terms[key]) {
terms[key].reset()
terms[key].write('\u001b[31mWebsocket connection failed!\u001b[0m')
}
}
}
return socket
}

View File

@ -60,9 +60,9 @@ class ExecConsole extends React.Component {
for (let key of Object.keys(store.outputs)) {
store.outputs[key]['status'] = 'websocket error'
if (this.terms[key]) {
this.terms[key].write('Websocket connection failed!')
this.terms[key].write('\u001b[31mWebsocket connection failed!\u001b[0m')
} else {
this.outputs[key] = 'Websocket connection failed!'
this.outputs[key] = '\u001b[31mWebsocket connection failed!\u001b[0m'
}
}
}