mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-04 08:55:40 +00:00
[Update] 修改websocket读取日志
This commit is contained in:
@@ -46,13 +46,20 @@ class CeleryLogWebsocket(JsonWebsocketConsumer):
|
|||||||
if not task_log_f:
|
if not task_log_f:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
task_end_mark = []
|
||||||
|
|
||||||
while not self.disconnected:
|
while not self.disconnected:
|
||||||
data = task_log_f.readline()
|
data = task_log_f.read(4096)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
data = data.replace(b'\n', b'\r\n')
|
data = data.replace(b'\n', b'\r\n')
|
||||||
self.send_json({'message': data.decode(errors='ignore'), 'task': task_id})
|
self.send_json({'message': data.decode(errors='ignore'), 'task': task_id})
|
||||||
if data.startswith(b'Task') and data.find(b'succeeded'):
|
if data.find(b'succeeded in') != -1:
|
||||||
|
task_end_mark.append(1)
|
||||||
|
if data.find(bytes(task_id, 'utf8')) != -1:
|
||||||
|
task_end_mark.append(1)
|
||||||
|
if len(task_end_mark) == 2:
|
||||||
|
logger.debug('Task log end: {}'.format(task_id))
|
||||||
break
|
break
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
task_log_f.close()
|
task_log_f.close()
|
||||||
|
Reference in New Issue
Block a user