From bf02d0775962b2379607692a8a54e938e86a21eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 13 Oct 2018 22:39:03 -0400 Subject: [PATCH] Added restart after update --- bazarr/check_update.py | 5 ++++- bazarr/main.py | 31 ++++++++----------------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/bazarr/check_update.py b/bazarr/check_update.py index 787c18956..1eeb314ef 100644 --- a/bazarr/check_update.py +++ b/bazarr/check_update.py @@ -46,4 +46,7 @@ def updated(): c = conn.cursor() c.execute("UPDATE system SET updated = 1") conn.commit() - c.close() \ No newline at end of file + c.close() + + from main import restart + restart() \ No newline at end of file diff --git a/bazarr/main.py b/bazarr/main.py index 3fd71d506..aba9d0b97 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -51,7 +51,6 @@ def configure_logging(): logging.getLogger("apscheduler").setLevel(logging.WARNING) logging.getLogger("subliminal").setLevel(logging.CRITICAL) logging.getLogger("stevedore.extension").setLevel(logging.CRITICAL) - #logging.getLogger("cherrypy").propagate = False root = logging.getLogger() root.setLevel(log_level) root.addHandler(fh) @@ -195,27 +194,20 @@ def redirect_root(): @route(base_url + 'shutdown') def shutdown(): try: - stop_file = open(os.path.join(os.pardir, "bazarr.stop file"), "w") - except: - logging.CRITICAL('Cannot create bazarr.stop.') + stop_file = open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "bazarr.stop"), "w") + except Exception as e: + logging.error('Cannot create bazarr.stop file.') else: stop_file.write('') stop_file.close() - print "before" server.stop() - print "after" - try: - os._exit(0) - except Exception as e: - logging.exception('Error while exiting Bazarr.') - print "exited" @route(base_url + 'restart') def restart(): try: - restart_file = open(os.path.join(os.pardir, "bazarr.restart"), "w") - except: - logging.CRITICAL('Cannot create bazarr.restart file.') + restart_file = open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "bazarr.restart"), "w") + except Exception as e: + logging.error('Cannot create bazarr.restart file.') else: restart_file.write('') restart_file.close() @@ -1699,13 +1691,6 @@ import warnings # Mute DeprecationWarning warnings.simplefilter("ignore", DeprecationWarning) -#logging.info('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url)) -#server = run(host=ip, port=port, server='waitress', app=app) -#logging.info('Bazarr has been stopped.') - server = CherryPyWSGIServer((str(ip), int(port)), app) - -try: - server.start() -except KeyboardInterrupt: - server.stop() \ No newline at end of file +logging.info('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url)) +server.start() \ No newline at end of file