From b42b3dbce509a81ec1f60e69d30bbc547ec4dd87 Mon Sep 17 00:00:00 2001 From: Lukas Zapletal Date: Mon, 28 Apr 2014 09:48:17 +0200 Subject: [PATCH] Show main exception only with --verbose --- websockify/websocketproxy.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/websockify/websocketproxy.py b/websockify/websocketproxy.py index 7b3ec11..f9503b5 100755 --- a/websockify/websocketproxy.py +++ b/websockify/websocketproxy.py @@ -402,21 +402,27 @@ def websockify_init(): try: opts.target_port = int(opts.target_port) except: parser.error("Error parsing target port") - # Transform to absolute path as daemon may chdir - if opts.target_cfg: - opts.target_cfg = os.path.abspath(opts.target_cfg) + try: + # Transform to absolute path as daemon may chdir + if opts.target_cfg: + opts.target_cfg = os.path.abspath(opts.target_cfg) - # Create and start the WebSockets proxy - libserver = opts.libserver - del opts.libserver - if libserver: - # Use standard Python SocketServer framework - server = LibProxyServer(**opts.__dict__) - server.serve_forever() - else: - # Use internal service framework - server = WebSocketProxy(**opts.__dict__) - server.start_server() + # Create and start the WebSockets proxy + libserver = opts.libserver + del opts.libserver + if libserver: + # Use standard Python SocketServer framework + server = LibProxyServer(**opts.__dict__) + server.serve_forever() + else: + # Use internal service framework + server = WebSocketProxy(**opts.__dict__) + server.start_server() + except: + if opts.verbose: + raise + else: + print >> sys.stderr, 'Unexpected error:', sys.exc_info()[1] class LibProxyServer(ForkingMixIn, HTTPServer):