Merge branch 'fix/exit-code-tweak' into 'dev'

removed old exit handling logic

See merge request crafty-controller/crafty-commander!109
This commit is contained in:
Quentin 2021-12-06 05:50:48 +00:00
commit 12153b1207
6 changed files with 1 additions and 39 deletions

View File

@ -34,17 +34,6 @@ class MainPrompt(cmd.Cmd, object):
def emptyline():
pass
@staticmethod
def _clean_shutdown():
exit_file = os.path.join(helper.root_dir, "exit.txt")
try:
with open(exit_file, 'w') as f:
f.write("exit")
except Exception as e:
logger.critical("Unable to write exit file due to error: {}".format(e))
console.critical("Unable to write exit file due to error: {}".format(e))
def do_exit(self, line):
self.universal_exit()
@ -77,7 +66,6 @@ class MainPrompt(cmd.Cmd, object):
logger.info("Stopping all server daemons / threads")
console.info("Stopping all server daemons / threads - This may take a few seconds")
websocket_helper.disconnect_all()
self._clean_shutdown()
console.info('Waiting for main thread to stop')
while True:
if self.tasks_manager.get_main_thread_run_status():

View File

@ -230,16 +230,6 @@ class Helpers:
version_data.get('meta', '?'))
return str(version)
def do_exit(self):
exit_file = os.path.join(self.root_dir, 'exit.txt')
try:
open(exit_file, 'a').close()
except Exception as e:
logger.critical("Unable to create exit file!")
console.critical("Unable to create exit file!")
sys.exit(1)
def encode_pass(self, password):
return self.passhasher.hash(password)

View File

@ -171,12 +171,10 @@ class Server:
if not helper.check_path_exists(self.server_path):
logger.critical("Server path: {} does not seem to exits".format(self.server_path))
console.critical("Server path: {} does not seem to exits".format(self.server_path))
helper.do_exit()
if not helper.check_writeable(self.server_path):
logger.critical("Unable to write/access {}".format(self.server_path))
console.warning("Unable to write/access {}".format(self.server_path))
helper.do_exit()
def start_server(self, user_id):
if not user_id:

View File

@ -48,7 +48,6 @@ class TasksManager:
self.webserver_thread = threading.Thread(target=self.tornado.run_tornado, daemon=True, name='tornado_thread')
self.main_kill_switch_thread = threading.Thread(target=self.main_kill_switch, daemon=True, name="main_loop")
self.main_thread_exiting = False
self.schedule_thread = threading.Thread(target=self.scheduler_thread, daemon=True, name="scheduler")
@ -65,16 +64,6 @@ class TasksManager:
def get_main_thread_run_status(self):
return self.main_thread_exiting
def start_main_kill_switch_watcher(self):
self.main_kill_switch_thread.start()
def main_kill_switch(self):
while True:
if os.path.exists(os.path.join(helper.root_dir, 'exit.txt')):
logger.info("Found Exit File, stopping everything")
self._main_graceful_exit()
time.sleep(5)
def reload_schedule_from_db(self):
jobs = management_helper.get_schedules_enabled()
schedule.clear(tag='backup')
@ -122,7 +111,6 @@ class TasksManager:
def _main_graceful_exit(self):
try:
os.remove(helper.session_file)
os.remove(os.path.join(helper.root_dir, 'exit.txt'))
os.remove(os.path.join(helper.root_dir, '.header'))
self.controller.stop_all_servers()
except:

View File

@ -137,9 +137,6 @@ if __name__ == '__main__':
# refresh our cache and schedule for every 12 hoursour cache refresh for serverjars.com
tasks_manager.serverjar_cache_refresher()
# this should always be last
tasks_manager.start_main_kill_switch_watcher()
logger.info("Checking Internet/Port Service. This may take a minute.")
console.info("Checking Internet/Port Service. This may take a minute.")

View File

@ -2,6 +2,7 @@ cryptography~=3.4
argon2-cffi~=20.1
bleach~=3.1
colorama~=0.4
cryptography~=3.4
peewee~=3.13
pexpect~=4.8
psutil~=5.7