Commit c08819a7 authored by Likun Zhang's avatar Likun Zhang
Browse files

1. Raise CmdctlException instead of exiting when port is used by other...

1. Raise CmdctlException instead of exiting when port is used by other processes. 2. Make error message be more accurate.

git-svn-id: svn:// e5f2f494-b856-4b98-b285-d166d9295462
parent f7f4533d
......@@ -3,4 +3,5 @@
. Add check for the content of key/certificate file
(when cmdctl starts or is configured by bindctl).
. Use only one msgq/session to communicate with other modules?
. Add more test cases.
......@@ -444,8 +444,7 @@ class SecureHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
http.server.HTTPServer.__init__(self, server_address, RequestHandlerClass)
except socket.error as err:
sys.stderr.write("[b10-cmdctl] Error creating b10-cmdctl, because: %s \n" % str(err))
raise CmdctlException("Error creating server, because: %s \n" % str(err))
self.user_sessions = {}
self.idle_timeout = idle_timeout
......@@ -598,11 +597,13 @@ if __name__ == '__main__':
(options, args) = parser.parse_args()
run(options.addr, options.port, options.idle_timeout, options.verbose)
except as se:
except as err:
sys.stderr.write("[b10-cmdctl] Error creating b10-cmdctl, "
"is the command channel daemon running?\n")
except KeyboardInterrupt:
sys.stderr.write("[b10-cmdctl] exit from Cmdctl\n")
except CmdctlException as err:
sys.stderr.write("[b10-cmdctl] " + str(err) + "\n")
if httpd:
......@@ -397,13 +397,13 @@ class TestSecureHTTPServer(unittest.TestCase):
def test_addr_in_use(self):
server_one = None
server_one = SecureHTTPServer(('localhost', 8080),
server_one = SecureHTTPServer(('localhost', 53531),
except SystemExit:
except CmdctlException:
self.assertRaises(SystemExit, SecureHTTPServer, ('localhost', 8080),
self.assertRaises(CmdctlException, SecureHTTPServer, ('localhost', 53531),
MySecureHTTPRequestHandler, MyCommandControl)
if server_one:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment