diff --git a/spug_api/apps/deploy/views.py b/spug_api/apps/deploy/views.py index 3b61e80..c4af72d 100644 --- a/spug_api/apps/deploy/views.py +++ b/spug_api/apps/deploy/views.py @@ -135,8 +135,8 @@ class RequestDetailView(View): rds, key, counter = get_redis_connection(), f'{settings.REQUEST_KEY}:{r_id}', 0 data = rds.lrange(key, counter, counter + 9) while data: - counter += 10 for item in data: + counter += 1 item = json.loads(item.decode()) if 'data' in item: outputs[item['key']]['data'] += item['data'] @@ -145,6 +145,7 @@ class RequestDetailView(View): if 'status' in item: outputs[item['key']]['status'] = item['status'] data = rds.lrange(key, counter, counter + 9) + response['index'] = counter return json_response(response) def post(self, request, r_id): diff --git a/spug_api/libs/ssh.py b/spug_api/libs/ssh.py index 74deb4f..3ea87cd 100644 --- a/spug_api/libs/ssh.py +++ b/spug_api/libs/ssh.py @@ -82,7 +82,6 @@ class SSH: exit_code, line = -1, '' while True: line = channel.recv(8196).decode() - print(repr(line)) match = self.regex.search(line) if match: exit_code = int(line.rsplit()[-1]) diff --git a/spug_web/src/pages/deploy/request/Ext1Console.js b/spug_web/src/pages/deploy/request/Ext1Console.js index 7228fdd..b4235b2 100644 --- a/spug_web/src/pages/deploy/request/Ext1Console.js +++ b/spug_web/src/pages/deploy/request/Ext1Console.js @@ -26,7 +26,7 @@ function Ext1Console(props) { Object.assign(outputs, res.outputs) setTimeout(() => setFetching(false), 100) if (res.status === '2') { - socket = _makeSocket() + socket = _makeSocket(res.index) } }) return () => socket && socket.close() @@ -44,8 +44,7 @@ function Ext1Console(props) { return () => socket && socket.close() } - function _makeSocket() { - let index = 0; + function _makeSocket(index = 0) { const token = props.request.id; const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; const socket = new WebSocket(`${protocol}//${window.location.host}/api/ws/request/${token}/?x-token=${X_TOKEN}`); diff --git a/spug_web/src/pages/deploy/request/Ext2Console.js b/spug_web/src/pages/deploy/request/Ext2Console.js index 8347672..30cac51 100644 --- a/spug_web/src/pages/deploy/request/Ext2Console.js +++ b/spug_web/src/pages/deploy/request/Ext2Console.js @@ -30,7 +30,7 @@ function Ext2Console(props) { Object.assign(outputs, res.outputs); setTimeout(() => setFetching(false), 100) if (res.status === '2') { - socket = _makeSocket() + socket = _makeSocket(res.index) } }) return () => socket && socket.close() @@ -49,8 +49,7 @@ function Ext2Console(props) { return () => socket && socket.close() } - function _makeSocket() { - let index = 0; + function _makeSocket(index = 0) { const token = props.request.id; const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; const socket = new WebSocket(`${protocol}//${window.location.host}/api/ws/request/${token}/?x-token=${X_TOKEN}`);