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
16d758ec
Commit
16d758ec
authored
May 18, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 更新debug
parent
b3693eca
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
10 deletions
+16
-10
app.py
coco/app.py
+13
-4
httpd.py
coco/httpd.py
+3
-4
models.py
coco/models.py
+0
-1
utils.py
coco/utils.py
+0
-1
No files found.
coco/app.py
View file @
16d758ec
...
...
@@ -9,6 +9,8 @@ import threading
import
socket
import
json
import
signal
import
objgraph
import
gc
from
jms.service
import
AppService
...
...
@@ -132,6 +134,7 @@ class Coco:
def
heartbeat
(
self
):
_sessions
=
[
s
.
to_json
()
for
s
in
self
.
sessions
]
tasks
=
self
.
service
.
terminal_heartbeat
(
_sessions
)
gc
.
collect
()
if
tasks
:
self
.
handle_task
(
tasks
)
if
tasks
is
False
:
...
...
@@ -219,13 +222,19 @@ class Coco:
def
add_client
(
self
,
client
):
with
self
.
lock
:
self
.
clients
.
append
(
client
)
logger
.
info
(
"New client {} join, total {} now"
.
format
(
client
,
len
(
self
.
clients
)))
logger
.
info
(
"New client {} join, total {} now"
.
format
(
client
,
len
(
self
.
clients
)
)
)
def
remove_client
(
self
,
client
):
with
self
.
lock
:
try
:
self
.
clients
.
remove
(
client
)
logger
.
info
(
"Client {} leave, total {} now"
.
format
(
client
,
len
(
self
.
clients
)))
logger
.
info
(
"Client {} leave, total {} now"
.
format
(
client
,
len
(
self
.
clients
)
)
)
client
.
close
()
except
:
pass
...
...
@@ -242,4 +251,5 @@ class Coco:
self
.
sessions
.
remove
(
session
)
self
.
service
.
finish_session
(
session
.
to_json
())
except
ValueError
:
logger
.
warning
(
"Remove session: {} fail, maybe already removed"
.
format
(
session
))
\ No newline at end of file
msg
=
"Remove session: {} fail, maybe already removed"
logger
.
warning
(
msg
.
format
(
session
))
coco/httpd.py
View file @
16d758ec
...
...
@@ -212,8 +212,7 @@ class ProxyNamespace(BaseNamespace):
def
on_disconnect
(
self
):
logger
.
debug
(
"On disconnect event trigger"
)
room_id_list
=
list
(
self
.
connections
.
get
(
request
.
sid
,
{})
.
keys
())
for
room_id
in
room_id_list
:
for
room_id
in
self
.
connections
.
get
(
request
.
sid
,
{}):
try
:
self
.
on_logout
(
room_id
)
except
Exception
as
e
:
...
...
@@ -250,14 +249,14 @@ class HttpServer:
self
.
flask_app
.
config
.
update
(
config
)
self
.
socket_io
=
SocketIO
()
self
.
register_routes
()
self
.
register_error_handler
()
def
register_routes
(
self
):
self
.
socket_io
.
on_namespace
(
ProxyNamespace
(
'/ssh'
))
@staticmethod
def
on_error_default
(
e
):
traceback
.
print_exc
()
logger
.
warn
(
e
)
logger
.
exception
(
e
)
def
register_error_handler
(
self
):
self
.
socket_io
.
on_error_default
(
self
.
on_error_default
)
...
...
coco/models.py
View file @
16d758ec
...
...
@@ -251,7 +251,6 @@ class WSProxy:
if
len
(
data
)
==
0
:
self
.
close
()
data
=
data
.
decode
(
errors
=
"ignore"
)
print
(
"Send data: {}"
.
format
(
data
))
self
.
ws
.
emit
(
"data"
,
{
'data'
:
data
,
'room'
:
self
.
room_id
},
room
=
self
.
room_id
)
if
len
(
data
)
==
BUF_SIZE
:
...
...
coco/utils.py
View file @
16d758ec
...
...
@@ -396,7 +396,6 @@ def size_of_str_with_zh(s):
try
:
chinese
=
find_chinese
(
s
)
except
TypeError
:
print
(
type
(
s
))
raise
return
len
(
s
)
+
len
(
chinese
)
...
...
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