Wait for server to become avaliable
This commit is contained in:
parent
fc95b26c45
commit
11a4c760d7
1 changed files with 10 additions and 4 deletions
|
@ -347,6 +347,7 @@ except (IOError, ExceptionInConfigError):
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
while 1:
|
||||||
ws = Handler(config.server_address)
|
ws = Handler(config.server_address)
|
||||||
# setup has to be called before the connection is established
|
# setup has to be called before the connection is established
|
||||||
ws.setup({"subscribe" : Subscribe(), "sensor" : Sensor(),
|
ws.setup({"subscribe" : Subscribe(), "sensor" : Sensor(),
|
||||||
|
@ -354,7 +355,12 @@ try:
|
||||||
"stop_programs" : StopPrograms(), "shutdown" : Shutdown(),
|
"stop_programs" : StopPrograms(), "shutdown" : Shutdown(),
|
||||||
"reboot" : Reboot(), "output" : Output()},
|
"reboot" : Reboot(), "output" : Output()},
|
||||||
debug=False)
|
debug=False)
|
||||||
|
try:
|
||||||
ws.connect()
|
ws.connect()
|
||||||
|
break
|
||||||
|
except ConnectionRefusedError:
|
||||||
|
Logging.warning("Server not running... Retrying in 5s")
|
||||||
|
time.sleep(5)
|
||||||
ws.run_forever()
|
ws.run_forever()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
ws.close()
|
ws.close()
|
||||||
|
|
Reference in a new issue