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
e4ccb1c4
Commit
e4ccb1c4
authored
Nov 03, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复日志打印的异常bug
parent
9d75ad6c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
run_log_watch.py
run_log_watch.py
+14
-6
No files found.
run_log_watch.py
View file @
e4ccb1c4
...
...
@@ -22,6 +22,17 @@ define("port", default=8080, help="run on the given port", type=int)
define
(
"host"
,
default
=
'0.0.0.0'
,
help
=
"run port on"
,
type
=
str
)
class
MyThread
(
threading
.
Thread
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
MyThread
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
run
(
self
):
try
:
super
(
MyThread
,
self
)
.
run
()
except
WebSocketClosedError
:
pass
class
EventHandler
(
ProcessEvent
):
def
__init__
(
self
,
client
=
None
):
self
.
client
=
client
...
...
@@ -34,10 +45,7 @@ class EventHandler(ProcessEvent):
def
process_IN_MODIFY
(
self
,
event
):
print
"Modify file:
%
s."
%
os
.
path
.
join
(
event
.
path
,
event
.
name
)
try
:
self
.
client
.
write_message
(
f
.
read
())
except
WebSocketClosedError
:
raise
WebSocketClosedError
self
.
client
.
write_message
(
f
.
read
())
def
file_monitor
(
path
=
'.'
,
client
=
None
):
...
...
@@ -99,7 +107,7 @@ class MonitorHandler(tornado.websocket.WebSocketHandler):
# 获取监控的path
self
.
file_path
=
self
.
get_argument
(
'file_path'
,
''
)
MonitorHandler
.
clients
.
append
(
self
)
thread
=
threading
.
Thread
(
target
=
file_monitor
,
args
=
(
'
%
s.log'
%
self
.
file_path
,
self
))
thread
=
My
Thread
(
target
=
file_monitor
,
args
=
(
'
%
s.log'
%
self
.
file_path
,
self
))
MonitorHandler
.
threads
.
append
(
thread
)
self
.
stream
.
set_nodelay
(
True
)
...
...
@@ -116,7 +124,7 @@ class MonitorHandler(tornado.websocket.WebSocketHandler):
t
.
setDaemon
(
True
)
t
.
start
()
except
WebSocketClosedError
,
e
:
except
WebSocketClosedError
:
client_index
=
MonitorHandler
.
clients
.
index
(
self
)
MonitorHandler
.
threads
[
client_index
]
.
stop
()
MonitorHandler
.
clients
.
remove
(
self
)
...
...
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