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
93e8c9e5
Unverified
Commit
93e8c9e5
authored
Oct 23, 2019
by
老广
Committed by
GitHub
Oct 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3374 from jumpserver/dev
Dev
parents
1c92516f
0b405fde
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
37 deletions
+86
-37
celery_task_log.html
apps/ops/templates/ops/celery_task_log.html
+25
-2
command_execution_create.html
apps/ops/templates/ops/command_execution_create.html
+23
-3
ws.py
apps/ops/ws.py
+38
-32
No files found.
apps/ops/templates/ops/celery_task_log.html
View file @
93e8c9e5
...
@@ -6,15 +6,37 @@
...
@@ -6,15 +6,37 @@
<script
src=
"{% static 'js/plugins/xterm/xterm.js' %}"
></script>
<script
src=
"{% static 'js/plugins/xterm/xterm.js' %}"
></script>
<script
src=
"{% static 'js/plugins/xterm/addons/fit/fit.js' %}"
></script>
<script
src=
"{% static 'js/plugins/xterm/addons/fit/fit.js' %}"
></script>
<link
rel=
"stylesheet"
href=
"{% static 'js/plugins/xterm/xterm.css' %}"
/>
<link
rel=
"stylesheet"
href=
"{% static 'js/plugins/xterm/xterm.css' %}"
/>
<link
rel=
"shortcut icon"
href=
"{{ FAVICON_URL }}"
type=
"image/x-icon"
>
<style>
<style>
body
{
body
{
background-color
:
black
;
background-color
:
black
;
}
}
.xterm-rows
{
.xterm-rows
{
{#
padding
:
15px
;
#
}
font-family
:
"Bitstream Vera Sans Mono"
,
Monaco
,
"Consolas"
,
Courier
,
monospace
;
font-family
:
"Bitstream Vera Sans Mono"
,
Monaco
,
"Consolas"
,
Courier
,
monospace
;
font-size
:
13px
;
font-size
:
13px
;
}
}
.terminal
.xterm-viewport
{
background-color
:
#1f1b1b
;
overflow
:
auto
;
}
body
::-webkit-scrollbar-track
{
-webkit-box-shadow
:
inset
0
0
2px
rgba
(
0
,
0
,
0
,
0.3
);
background-color
:
#272323
;
border-radius
:
6px
;
}
body
::-webkit-scrollbar
{
width
:
8px
;
height
:
8px
;
}
body
::-webkit-scrollbar-thumb
{
background-color
:
#494141
;
border-radius
:
6px
;
}
</style>
</style>
</head>
</head>
<div
id=
"term"
style=
"height: 100%;width: 100%"
>
<div
id=
"term"
style=
"height: 100%;width: 100%"
>
...
@@ -36,7 +58,8 @@
...
@@ -36,7 +58,8 @@
cursorBlink
:
false
,
cursorBlink
:
false
,
screenKeys
:
false
,
screenKeys
:
false
,
fontFamily
:
'"Monaco", "Consolas", "monospace"'
,
fontFamily
:
'"Monaco", "Consolas", "monospace"'
,
fontSize
:
12
,
fontSize
:
13
,
lineHeight
:
1.2
,
rightClickSelectsWord
:
true
,
rightClickSelectsWord
:
true
,
disableStdin
:
true
disableStdin
:
true
});
});
...
...
apps/ops/templates/ops/command_execution_create.html
View file @
93e8c9e5
...
@@ -34,6 +34,27 @@
...
@@ -34,6 +34,27 @@
.select2-container
.select2-selection--single
{
.select2-container
.select2-selection--single
{
height
:
34px
;
height
:
34px
;
}
}
.terminal
.xterm-viewport
{
background-color
:
#1f1b1b
;
overflow
:
auto
;
}
body
::-webkit-scrollbar-track
{
-webkit-box-shadow
:
inset
0
0
2px
rgba
(
0
,
0
,
0
,
0.3
);
background-color
:
#272323
;
border-radius
:
6px
;
}
body
::-webkit-scrollbar
{
width
:
8px
;
height
:
8px
;
}
body
::-webkit-scrollbar-thumb
{
background-color
:
#494141
;
border-radius
:
6px
;
}
</style>
</style>
{% endblock %}
{% endblock %}
...
@@ -201,11 +222,10 @@
...
@@ -201,11 +222,10 @@
cursorBlink
:
false
,
cursorBlink
:
false
,
screenKeys
:
false
,
screenKeys
:
false
,
fontFamily
:
'monaco, Consolas, "Lucida Console", monospace'
,
fontFamily
:
'monaco, Consolas, "Lucida Console", monospace'
,
fontSize
:
14
,
fontSize
:
13
,
lineHeight
:
1
,
rightClickSelectsWord
:
true
,
rightClickSelectsWord
:
true
,
disableStdin
:
true
,
disableStdin
:
true
,
cursorBlink
:
false
,
lineHeight
:
1.2
,
theme
:
{
theme
:
{
background
:
'#1f1b1b'
background
:
'#1f1b1b'
}
}
...
...
apps/ops/ws.py
View file @
93e8c9e5
...
@@ -23,40 +23,46 @@ class CeleryLogWebsocket(JsonWebsocketConsumer):
...
@@ -23,40 +23,46 @@ class CeleryLogWebsocket(JsonWebsocketConsumer):
if
task_id
:
if
task_id
:
self
.
handle_task
(
task_id
)
self
.
handle_task
(
task_id
)
def
handle_task
(
self
,
task_id
):
def
wait_util_log_path_exist
(
self
,
task_id
):
logger
.
info
(
"Task id: {}"
.
format
(
task_id
))
log_path
=
get_celery_task_log_path
(
task_id
)
log_path
=
get_celery_task_log_path
(
task_id
)
while
not
self
.
disconnected
:
if
not
os
.
path
.
exists
(
log_path
):
self
.
send_json
({
'message'
:
'.'
,
'task'
:
task_id
})
time
.
sleep
(
0.5
)
continue
self
.
send_json
({
'message'
:
'
\r\n
'
})
try
:
logger
.
debug
(
'Task log path: {}'
.
format
(
log_path
))
task_log_f
=
open
(
log_path
,
'rb'
)
return
task_log_f
except
OSError
:
return
None
def
read_log_file
(
self
,
task_id
):
task_log_f
=
self
.
wait_util_log_path_exist
(
task_id
)
if
not
task_log_f
:
return
task_end_mark
=
[]
while
not
self
.
disconnected
:
data
=
task_log_f
.
read
(
4096
)
if
data
:
data
=
data
.
replace
(
b
'
\n
'
,
b
'
\r\n
'
)
self
.
send_json
(
{
'message'
:
data
.
decode
(
errors
=
'ignore'
),
'task'
:
task_id
})
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
)
elif
len
(
task_end_mark
)
==
2
:
logger
.
debug
(
'Task log end: {}'
.
format
(
task_id
))
break
time
.
sleep
(
0.2
)
task_log_f
.
close
()
def
func
():
def
handle_task
(
self
,
task_id
):
task_log_f
=
None
logger
.
info
(
"Task id: {}"
.
format
(
task_id
))
thread
=
threading
.
Thread
(
target
=
self
.
read_log_file
,
args
=
(
task_id
,))
while
not
self
.
disconnected
:
if
not
os
.
path
.
exists
(
log_path
):
self
.
send_json
({
'message'
:
'.'
,
'task'
:
task_id
})
time
.
sleep
(
0.5
)
continue
self
.
send_json
({
'message'
:
'
\r\n
'
})
try
:
logger
.
debug
(
'Task log path: {}'
.
format
(
log_path
))
task_log_f
=
open
(
log_path
,
'rb'
)
break
except
OSError
:
return
if
not
task_log_f
:
return
while
not
self
.
disconnected
:
data
=
task_log_f
.
readline
()
if
data
:
data
=
data
.
replace
(
b
'
\n
'
,
b
'
\r\n
'
)
self
.
send_json
({
'message'
:
data
.
decode
(
errors
=
'ignore'
),
'task'
:
task_id
})
if
data
.
startswith
(
b
'Task'
)
and
data
.
find
(
b
'succeeded'
):
break
time
.
sleep
(
0.1
)
task_log_f
.
close
()
thread
=
threading
.
Thread
(
target
=
func
)
thread
.
start
()
thread
.
start
()
def
disconnect
(
self
,
close_code
):
def
disconnect
(
self
,
close_code
):
...
...
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