Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
telemersion
Telemersive Switchboard
Commits
a6997adc
Commit
a6997adc
authored
Feb 19, 2021
by
Roman Haefeli
Browse files
add proper gunicorn logging to switchboard app
parent
0dc5937a
Changes
1
Hide whitespace changes
Inline
Side-by-side
switchboard.py
View file @
a6997adc
...
...
@@ -6,6 +6,7 @@ tpf-switchboard creates and destroys udp proxies dynamically on request.
"""
import
copy
import
logging
import
sys
import
time
import
proxies
...
...
@@ -31,6 +32,12 @@ listen_address = '0.0.0.0'
app
=
Flask
(
__name__
)
app
.
logger
.
handlers
=
logging
.
getLogger
(
'gunicorn.error'
).
handlers
#gunicorn_error_handlers = logging.getLogger('gunicorn.error').handlers
#app.logger.handlers.extend(gunicorn_error_handlers )
app
.
logger
.
setLevel
(
logging
.
INFO
)
app
.
config
[
'PROPAGATE_EXCEPTIONS'
]
=
True
class
r
(
Response
):
default_mimetype
=
'application/json'
...
...
@@ -97,7 +104,7 @@ def start_proxy():
except
KeyError
:
try
:
if
proxydef
[
'type'
]
==
'one2oneBi'
:
obj
=
proxies
.
One2OneBiProxy
(
listen_port
=
proxydef
[
'port'
])
obj
=
proxies
.
One2OneBiProxy
(
listen_port
=
proxydef
[
'port'
]
,
logger
=
app
.
logger
)
elif
proxydef
[
'type'
]
==
'one2manyMo'
:
obj
=
proxies
.
One2ManyMoProxy
(
listen_port
=
proxydef
[
'port'
],
send_port
=
proxydef
[
'port'
]
+
1
)
elif
proxydef
[
'type'
]
==
'mirror'
:
...
...
@@ -122,6 +129,7 @@ def start_proxy():
'room'
:
proxydef
[
'room'
]
}
response
=
{
'status'
:
'OK'
,
'msg'
:
'Proxy successfully started'
}
app
.
logger
.
info
(
'Proxy of type "%s" successfully started on port "%s"'
,
proxydef
[
'type'
],
proxydef
[
'port'
])
return
r
(
json
.
dumps
(
response
),
201
)
else
:
response
=
{
'status'
:
'Error'
,
'msg'
:
'Proxy already running on port %s'
%
proxydef
[
'port'
]}
...
...
@@ -131,6 +139,8 @@ def start_proxy():
def
stop_proxy
(
port
):
try
:
myproxies
[
port
][
'obj'
].
stop
()
myproxies
[
port
][
'obj'
].
join
()
app
.
logger
.
info
(
'Proxy of type "%s" running on port "%s" successfully stopped'
,
myproxies
[
port
][
'type'
],
port
)
del
myproxies
[
port
]
response
=
{
'status'
:
'OK'
,
'msg'
:
'Proxy successfully stopped'
}
return
r
(
json
.
dumps
(
response
))
...
...
Write
Preview
Supports
Markdown
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