mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-12 13:12:35 +01:00
httpserver: improve error handling when binding ports
1. better error messages 2. try binding other ports even if one fails
This commit is contained in:
parent
ce03729f20
commit
9bfa1458ef
@ -468,7 +468,24 @@ def startServer():
|
|||||||
for x in configGroup.hosts6() if x != '']
|
for x in configGroup.hosts6() if x != '']
|
||||||
http_servers = []
|
http_servers = []
|
||||||
for protocol, address in (addresses4 + addresses6):
|
for protocol, address in (addresses4 + addresses6):
|
||||||
|
try:
|
||||||
server = SupyHTTPServer(address, protocol, SupyHTTPRequestHandler)
|
server = SupyHTTPServer(address, protocol, SupyHTTPRequestHandler)
|
||||||
|
except OSError as e:
|
||||||
|
log.error(
|
||||||
|
'Failed to start HTTP server with protocol %s at address: %s',
|
||||||
|
protocol, address, e)
|
||||||
|
if e.args[0] == 98:
|
||||||
|
log.error(
|
||||||
|
'This means the port (and address) is already in use by an '
|
||||||
|
'other process. Either find the process using the port '
|
||||||
|
'and stop it, or change the port configured in '
|
||||||
|
'supybot.servers.http.port.')
|
||||||
|
continue
|
||||||
|
except:
|
||||||
|
log.exception(
|
||||||
|
"Failed to start HTTP server with protocol %s at address",
|
||||||
|
protocol, address)
|
||||||
|
continue
|
||||||
Thread(target=server.serve_forever, name='HTTP Server').start()
|
Thread(target=server.serve_forever, name='HTTP Server').start()
|
||||||
http_servers.append(server)
|
http_servers.append(server)
|
||||||
log.info('Starting HTTP server: %s' % str(server))
|
log.info('Starting HTTP server: %s' % str(server))
|
||||||
|
Loading…
Reference in New Issue
Block a user