From 23ce45724a0176bea5de4f8c3514c2638deb8e98 Mon Sep 17 00:00:00 2001 From: luukas Date: Sun, 18 Apr 2021 00:24:54 +0300 Subject: [PATCH] Create universal exit function so exiting code can be in one place. --- app/classes/shared/cmd.py | 3 +++ main.py | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/classes/shared/cmd.py b/app/classes/shared/cmd.py index e8c1570f..fef1b426 100644 --- a/app/classes/shared/cmd.py +++ b/app/classes/shared/cmd.py @@ -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() diff --git a/main.py b/main.py index 52821a17..71fd2489 100644 --- a/main.py +++ b/main.py @@ -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()