try binding again, backoff if failed
This commit is contained in:
parent
3c7ee16f43
commit
b3d920b295
|
@ -212,7 +212,22 @@ class MinecraftServerBridge(socket_util):
|
|||
def socket_reset(self):
|
||||
super().socket_reset()
|
||||
LOG.info("Server Binding to " + self.host + " " + str(self.port))
|
||||
self.soc.bind((self.host, self.port))
|
||||
while True:
|
||||
backoff = 1
|
||||
try:
|
||||
self.soc.bind((self.host, self.port))
|
||||
break
|
||||
except OSError as e:
|
||||
if e.errno == 98:
|
||||
LOG.warning(
|
||||
"Unable to bind to port {}, trying again in {} seconds".format(
|
||||
self.port, backoff
|
||||
)
|
||||
)
|
||||
time.sleep(backoff)
|
||||
backoff *= 2
|
||||
else:
|
||||
raise e
|
||||
LOG.info("Server Bound")
|
||||
self.soc.listen(1)
|
||||
LOG.info("Server listen to host")
|
||||
|
@ -355,7 +370,7 @@ def make_config(configfile, server=True):
|
|||
|
||||
|
||||
def main():
|
||||
logging.basicConfig()
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
mode_group = parser.add_mutually_exclusive_group(required=True)
|
||||
|
|
Loading…
Reference in New Issue