Exit gracefully when socket fails to open
This fixes prevents a traceback that was shown when trying to listen to an address on which 'bind' fails.
This commit is contained in:
parent
99f83ca083
commit
f05cd203de
|
|
@ -718,6 +718,7 @@ class WebSockifyServer():
|
||||||
be overridden) for each new client connection.
|
be overridden) for each new client connection.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
if self.listen_fd != None:
|
if self.listen_fd != None:
|
||||||
lsock = socket.fromfd(self.listen_fd, socket.AF_INET, socket.SOCK_STREAM)
|
lsock = socket.fromfd(self.listen_fd, socket.AF_INET, socket.SOCK_STREAM)
|
||||||
elif self.unix_listen != None:
|
elif self.unix_listen != None:
|
||||||
|
|
@ -732,6 +733,10 @@ class WebSockifyServer():
|
||||||
tcp_keepcnt=self.tcp_keepcnt,
|
tcp_keepcnt=self.tcp_keepcnt,
|
||||||
tcp_keepidle=self.tcp_keepidle,
|
tcp_keepidle=self.tcp_keepidle,
|
||||||
tcp_keepintvl=self.tcp_keepintvl)
|
tcp_keepintvl=self.tcp_keepintvl)
|
||||||
|
except OSError as e:
|
||||||
|
self.msg("Openening socket failed: %s", str(e))
|
||||||
|
self.vmsg("exception", exc_info=True)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
if self.daemon:
|
if self.daemon:
|
||||||
keepfd = self.get_log_fd()
|
keepfd = self.get_log_fd()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue