Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
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
coco
Commits
bf122400
Commit
bf122400
authored
Sep 12, 2018
by
广宏伟
Browse files
Options
Browse Files
Download
Plain Diff
Merged in dev (pull request #100)
[Update] 增加异常捕捉
parents
30c2bb36
28292df8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
14 deletions
+26
-14
app.py
coco/app.py
+18
-12
httpd.py
coco/httpd.py
+4
-1
sshd.py
coco/sshd.py
+4
-1
No files found.
coco/app.py
View file @
bf122400
...
...
@@ -105,7 +105,10 @@ class Coco:
def
keep_heartbeat
(
self
):
def
func
():
while
not
self
.
stop_evt
.
is_set
():
self
.
heartbeat
()
try
:
self
.
heartbeat
()
except
Exception
as
e
:
logger
.
error
(
"Unexpected error occur: {}"
.
format
(
e
))
time
.
sleep
(
config
[
"HEARTBEAT_INTERVAL"
])
thread
=
threading
.
Thread
(
target
=
func
)
thread
.
start
()
...
...
@@ -151,17 +154,20 @@ class Coco:
def
func
():
while
not
self
.
stop_evt
.
is_set
():
sessions_copy
=
[
s
for
s
in
Session
.
sessions
.
values
()]
for
s
in
sessions_copy
:
# Session 没有正常关闭,
if
s
.
closed_unexpected
:
Session
.
remove_session
(
s
.
id
)
continue
# Session已正常关闭
if
s
.
closed
:
Session
.
remove_session
(
s
)
else
:
check_session_idle_too_long
(
s
)
try
:
sessions_copy
=
[
s
for
s
in
Session
.
sessions
.
values
()]
for
s
in
sessions_copy
:
# Session 没有正常关闭,
if
s
.
closed_unexpected
:
Session
.
remove_session
(
s
.
id
)
continue
# Session已正常关闭
if
s
.
closed
:
Session
.
remove_session
(
s
)
else
:
check_session_idle_too_long
(
s
)
except
Exception
as
e
:
logger
.
error
(
"Unexpected error occur: {}"
.
format
(
e
))
time
.
sleep
(
interval
)
thread
=
threading
.
Thread
(
target
=
func
)
thread
.
start
()
...
...
coco/httpd.py
View file @
bf122400
...
...
@@ -103,7 +103,10 @@ class ProxyNamespace(BaseNamespace):
forwarder
=
ProxyServer
(
client
,
asset
,
system_user
)
def
proxy
():
forwarder
.
proxy
()
try
:
forwarder
.
proxy
()
except
Exception
as
e
:
logger
.
error
(
"Unexpected error occur: {}"
.
format
(
e
))
self
.
logout
(
client_id
,
connection
)
self
.
socketio
.
start_background_task
(
proxy
)
...
...
coco/sshd.py
View file @
bf122400
...
...
@@ -110,7 +110,10 @@ class SSHServer:
kind
=
client
.
request
.
kind
if
kind
==
'session'
and
chan_type
in
supported
:
logger
.
info
(
"Request type `{}:{}`, dispatch to interactive mode"
.
format
(
kind
,
chan_type
))
InteractiveServer
(
client
)
.
interact
()
try
:
InteractiveServer
(
client
)
.
interact
()
except
Exception
as
e
:
logger
.
error
(
"Unexpected error occur: {}"
.
format
(
e
))
connection
=
Connection
.
get_connection
(
client
.
connection_id
)
connection
.
remove_client
(
client
.
id
)
elif
chan_type
==
'subsystem'
:
...
...
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