From 03d1cfa4904535093c2a1b3126b7bda7c775032c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 6 Nov 2019 06:50:35 -0500 Subject: [PATCH] Fix for restart after update failing and causing UI to become unresponsive. --- bazarr/main.py | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/bazarr/main.py b/bazarr/main.py index 8a865e889..e160f090e 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -178,31 +178,36 @@ def redirect_root(): @route(base_url + 'shutdown') def shutdown(): try: - stop_file = open(os.path.join(args.config_dir, "bazarr.stop"), "w") - except Exception as e: - logging.error('BAZARR Cannot create bazarr.stop file.') - else: server.stop() + except: + logging.error('BAZARR Cannot stop CherryPy.') + else: database.close() - stop_file.write('') - stop_file.close() - sys.exit(0) + try: + stop_file = open(os.path.join(args.config_dir, "bazarr.stop"), "w") + except Exception as e: + logging.error('BAZARR Cannot create bazarr.stop file.') + else: + stop_file.write('') + stop_file.close() @route(base_url + 'restart') def restart(): try: - restart_file = open(os.path.join(args.config_dir, "bazarr.restart"), "w") - except Exception as e: - logging.error('BAZARR Cannot create bazarr.restart file.') - else: - # print 'Bazarr is being restarted...' - logging.info('Bazarr is being restarted...') server.stop() + except: + logging.error('BAZARR Cannot stop CherryPy.') + else: database.close() - restart_file.write('') - restart_file.close() - sys.exit(0) + try: + restart_file = open(os.path.join(args.config_dir, "bazarr.restart"), "w") + except Exception as e: + logging.error('BAZARR Cannot create bazarr.restart file.') + else: + logging.info('Bazarr is being restarted...') + restart_file.write('') + restart_file.close() @route(base_url + 'wizard')