Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
44f8b978
Commit
44f8b978
authored
Sep 27, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 添加failover ws
parent
1a82b858
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
celery_task_log.html
apps/ops/templates/ops/celery_task_log.html
+11
-1
celery.py
apps/ops/views/celery.py
+5
-1
No files found.
apps/ops/templates/ops/celery_task_log.html
View file @
44f8b978
...
...
@@ -24,6 +24,8 @@
var
port
=
document
.
location
.
port
?
":"
+
document
.
location
.
port
:
""
;
var
url
=
"/ws/ops/tasks/"
+
"{{ task_id }}"
+
"/log/"
;
var
wsURL
=
scheme
+
"://"
+
document
.
location
.
hostname
+
port
+
url
;
var
failOverPort
=
"{{ ws_port }}"
;
var
failOverWsURL
=
scheme
+
"://"
+
document
.
location
.
hostname
+
':'
+
failOverPort
+
url
;
var
term
;
var
ws
;
...
...
@@ -38,13 +40,21 @@
});
term
.
open
(
document
.
getElementById
(
'term'
));
term
.
resize
(
120
,
30
);
ws
=
new
WebSocket
(
wsURL
);
ws
.
onmessage
=
function
(
e
)
{
var
data
=
JSON
.
parse
(
e
.
data
);
term
.
write
(
data
.
message
);
};
ws
.
onerror
=
function
(
e
)
{
term
.
write
(
"Connect websocket server error"
)
ws
=
new
WebSocket
(
failOverWsURL
);
ws
.
onmessage
=
function
(
e
)
{
var
data
=
JSON
.
parse
(
e
.
data
);
term
.
write
(
data
.
message
);
};
ws
.
onerror
=
function
(
e
)
{
term
.
write
(
"Connect websocket server error"
)
}
}
});
</script>
apps/ops/views/celery.py
View file @
44f8b978
# -*- coding: utf-8 -*-
#
from
django.views.generic
import
TemplateView
from
django.conf
import
settings
from
common.permissions
import
PermissionsMixin
,
IsOrgAdmin
,
IsOrgAuditor
...
...
@@ -14,5 +15,8 @@ class CeleryTaskLogView(PermissionsMixin, TemplateView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
.
update
({
'task_id'
:
self
.
kwargs
.
get
(
'pk'
)})
context
.
update
({
'task_id'
:
self
.
kwargs
.
get
(
'pk'
),
'ws_port'
:
settings
.
CONFIG
.
WS_LISTEN_PORT
})
return
context
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment