Added restart after update

pull/222/head
Louis Vézina 6 years ago
parent a88672070e
commit bf02d07759

@ -46,4 +46,7 @@ def updated():
c = conn.cursor() c = conn.cursor()
c.execute("UPDATE system SET updated = 1") c.execute("UPDATE system SET updated = 1")
conn.commit() conn.commit()
c.close() c.close()
from main import restart
restart()

@ -51,7 +51,6 @@ def configure_logging():
logging.getLogger("apscheduler").setLevel(logging.WARNING) logging.getLogger("apscheduler").setLevel(logging.WARNING)
logging.getLogger("subliminal").setLevel(logging.CRITICAL) logging.getLogger("subliminal").setLevel(logging.CRITICAL)
logging.getLogger("stevedore.extension").setLevel(logging.CRITICAL) logging.getLogger("stevedore.extension").setLevel(logging.CRITICAL)
#logging.getLogger("cherrypy").propagate = False
root = logging.getLogger() root = logging.getLogger()
root.setLevel(log_level) root.setLevel(log_level)
root.addHandler(fh) root.addHandler(fh)
@ -195,27 +194,20 @@ def redirect_root():
@route(base_url + 'shutdown') @route(base_url + 'shutdown')
def shutdown(): def shutdown():
try: try:
stop_file = open(os.path.join(os.pardir, "bazarr.stop file"), "w") stop_file = open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "bazarr.stop"), "w")
except: except Exception as e:
logging.CRITICAL('Cannot create bazarr.stop.') logging.error('Cannot create bazarr.stop file.')
else: else:
stop_file.write('') stop_file.write('')
stop_file.close() stop_file.close()
print "before"
server.stop() server.stop()
print "after"
try:
os._exit(0)
except Exception as e:
logging.exception('Error while exiting Bazarr.')
print "exited"
@route(base_url + 'restart') @route(base_url + 'restart')
def restart(): def restart():
try: try:
restart_file = open(os.path.join(os.pardir, "bazarr.restart"), "w") restart_file = open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "bazarr.restart"), "w")
except: except Exception as e:
logging.CRITICAL('Cannot create bazarr.restart file.') logging.error('Cannot create bazarr.restart file.')
else: else:
restart_file.write('') restart_file.write('')
restart_file.close() restart_file.close()
@ -1699,13 +1691,6 @@ import warnings
# Mute DeprecationWarning # Mute DeprecationWarning
warnings.simplefilter("ignore", 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) server = CherryPyWSGIServer((str(ip), int(port)), app)
logging.info('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url))
try: server.start()
server.start()
except KeyboardInterrupt:
server.stop()
Loading…
Cancel
Save