From 15895f4055ea7e765a2bd7548bbb974739182b53 Mon Sep 17 00:00:00 2001 From: marblepebble Date: Fri, 18 Aug 2017 21:38:32 +0100 Subject: [PATCH 1/5] Specify ip4 address to bind to --- cps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps.py b/cps.py index 523246b2..34e49cf2 100755 --- a/cps.py +++ b/cps.py @@ -30,7 +30,7 @@ if __name__ == '__main__': else: web.app.logger.info('Falling back to Tornado') http_server = HTTPServer(WSGIContainer(web.app)) - http_server.listen(web.ub.config.config_port) + http_server.listen(web.ub.config.config_port, '0.0.0.0') IOLoop.instance().start() IOLoop.instance().close(True) From 97f573c41afb7fea5e1075ba380ddd25464bf26b Mon Sep 17 00:00:00 2001 From: marblepebble Date: Fri, 18 Aug 2017 21:53:52 +0100 Subject: [PATCH 2/5] Set ipv4 address explicitly for docker usage --- cps/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index eec1760d..c89abca7 100755 --- a/cps/web.py +++ b/cps/web.py @@ -3094,5 +3094,5 @@ def upload(): def start_gevent(): from gevent.wsgi import WSGIServer global gevent_server - gevent_server = WSGIServer(('', ub.config.config_port), app) + gevent_server = WSGIServer(('0.0.0.0', ub.config.config_port), app) gevent_server.serve_forever() From b8b88183c3da2649d33efb55936352a58cf9ae57 Mon Sep 17 00:00:00 2001 From: Ainsley Pereira Date: Tue, 12 Sep 2017 20:49:38 +0100 Subject: [PATCH 3/5] Use IPv4-only WSGI start up as a fallback only when the IPv6/IPv4 one didn't work --- cps.py | 2 +- cps/web.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cps.py b/cps.py index 34e49cf2..523246b2 100755 --- a/cps.py +++ b/cps.py @@ -30,7 +30,7 @@ if __name__ == '__main__': else: web.app.logger.info('Falling back to Tornado') http_server = HTTPServer(WSGIContainer(web.app)) - http_server.listen(web.ub.config.config_port, '0.0.0.0') + http_server.listen(web.ub.config.config_port) IOLoop.instance().start() IOLoop.instance().close(True) diff --git a/cps/web.py b/cps/web.py index 2de55a15..a683dfe7 100755 --- a/cps/web.py +++ b/cps/web.py @@ -3046,5 +3046,8 @@ def upload(): def start_gevent(): from gevent.wsgi import WSGIServer global gevent_server - gevent_server = WSGIServer(('0.0.0.0', ub.config.config_port), app) + try: + gevent_server = WSGIServer(('', ub.config.config_port), app) + except socket.error: + gevent_server = WSGIServer(('0.0.0.0', ub.config.config_port), app) gevent_server.serve_forever() From 1ce6893fa898cec44909c34189aa2609a5039ebe Mon Sep 17 00:00:00 2001 From: Ainsley Pereira Date: Tue, 12 Sep 2017 21:06:58 +0100 Subject: [PATCH 4/5] Exception isn't thrown until we call serve_forever, so that must be in the try block --- cps/web.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index a683dfe7..54ef5eaa 100755 --- a/cps/web.py +++ b/cps/web.py @@ -3048,6 +3048,9 @@ def start_gevent(): global gevent_server try: gevent_server = WSGIServer(('', ub.config.config_port), app) + gevent_server.serve_forever() except socket.error: + app.logger.info('Unable to listen on \'\', trying on IPv4 only...') gevent_server = WSGIServer(('0.0.0.0', ub.config.config_port), app) - gevent_server.serve_forever() + gevent_server.serve_forever() + From 993c56d0217fba833bdfcc4b1f75454a38013c35 Mon Sep 17 00:00:00 2001 From: Ainsley Pereira Date: Tue, 12 Sep 2017 21:11:52 +0100 Subject: [PATCH 5/5] Fix syntax error --- cps/web.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index 54ef5eaa..86728853 100755 --- a/cps/web.py +++ b/cps/web.py @@ -79,6 +79,7 @@ import hashlib from redirect import redirect_back, is_safe_url from tornado import version as tornadoVersion +from socket import error as SocketError try: from urllib.parse import quote @@ -3049,7 +3050,7 @@ def start_gevent(): try: gevent_server = WSGIServer(('', ub.config.config_port), app) gevent_server.serve_forever() - except socket.error: + except SocketError: app.logger.info('Unable to listen on \'\', trying on IPv4 only...') gevent_server = WSGIServer(('0.0.0.0', ub.config.config_port), app) gevent_server.serve_forever()