From 9241cbe8377367f6355409634dd9fccae6387bed Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Tue, 23 Jun 2015 08:49:29 +0200 Subject: [PATCH] Show understandable error when binding to the port fails. --- src/scriptform.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/scriptform.py b/src/scriptform.py index 8617ba9..ef45e6e 100755 --- a/src/scriptform.py +++ b/src/scriptform.py @@ -39,6 +39,7 @@ import json import logging import thread import hashlib +import socket from daemon import Daemon from formdefinition import FormDefinition @@ -229,6 +230,13 @@ def main(): # pragma: no cover elif options.action_stop: daemon.stop() sys.exit(0) + except socket.error, err: + log.exception(err) + sys.stderr.write("Cannot bind to port {}: {}\n".format( + options.port, + str(err) + )) + sys.exit(2) except Exception, err: log.exception(err) raise