Create universal exit function so exiting code can be in one place.

This commit is contained in:
luukas 2021-04-18 00:24:54 +03:00
parent 736924c839
commit 23ce45724a
2 changed files with 4 additions and 7 deletions

View File

@ -49,6 +49,9 @@ class MainPrompt(cmd.Cmd, object):
console.critical("Unable to write exit file due to error: {}".format(e))
def do_exit(self, line):
self.universal_exit()
def universal_exit(self):
logger.info("Stopping all server daemons / threads")
console.info("Stopping all server daemons / threads - This may take a few seconds")
websocket_helper.disconnect_all()

View File

@ -141,10 +141,4 @@ if __name__ == '__main__':
logger.info("Recieved SIGINT, stopping Crafty")
break
logger.info("Stopping all server daemons / threads")
console.info("Stopping all server daemons / threads - This may take a few seconds")
Crafty._clean_shutdown()
while True:
if tasks_manager.get_main_thread_run_status():
sys.exit(0)
time.sleep(1)
Crafty.universal_exit()