mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 10:16:11 +00:00
Fix service restart
This commit is contained in:
parent
5db5372db5
commit
25ed1cb011
4 changed files with 47 additions and 13 deletions
|
@ -13,6 +13,7 @@ from emby import Emby
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
Emby.set_loghandler(loghandler.LogHandler, logging.DEBUG)
|
Emby.set_loghandler(loghandler.LogHandler, logging.DEBUG)
|
||||||
|
loghandler.reset()
|
||||||
loghandler.config()
|
loghandler.config()
|
||||||
LOG = logging.getLogger('EMBY.entrypoint')
|
LOG = logging.getLogger('EMBY.entrypoint')
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,6 @@ class Service(xbmc.Monitor):
|
||||||
|
|
||||||
window('emby.restart', clear=True)
|
window('emby.restart', clear=True)
|
||||||
dialog("notification", heading="{emby}", message=_(33193), icon="{emby}", time=1000, sound=False)
|
dialog("notification", heading="{emby}", message=_(33193), icon="{emby}", time=1000, sound=False)
|
||||||
reload(objects)
|
|
||||||
|
|
||||||
raise Exception('RestartService')
|
raise Exception('RestartService')
|
||||||
|
|
||||||
|
@ -215,7 +214,7 @@ class Service(xbmc.Monitor):
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
LOG.exception(error)
|
LOG.exception(error)
|
||||||
|
|
||||||
return True
|
raise Exception("RestartService")
|
||||||
|
|
||||||
def onNotification(self, sender, method, data):
|
def onNotification(self, sender, method, data):
|
||||||
|
|
||||||
|
@ -422,9 +421,12 @@ class Service(xbmc.Monitor):
|
||||||
|
|
||||||
elif method == 'CheckUpdate':
|
elif method == 'CheckUpdate':
|
||||||
|
|
||||||
if not self.check_update(True):
|
try:
|
||||||
|
self.check_update(True)
|
||||||
dialog("notification", heading="{emby}", message=_(21341), icon="{emby}", sound=False)
|
dialog("notification", heading="{emby}", message=_(21341), icon="{emby}", sound=False)
|
||||||
else:
|
except Exception as error:
|
||||||
|
if 'RestartService' in error:
|
||||||
|
|
||||||
dialog("notification", heading="{emby}", message=_(33181), icon="{emby}", sound=False)
|
dialog("notification", heading="{emby}", message=_(33181), icon="{emby}", sound=False)
|
||||||
window('emby.restart.bool', True)
|
window('emby.restart.bool', True)
|
||||||
|
|
||||||
|
@ -499,6 +501,8 @@ class Service(xbmc.Monitor):
|
||||||
self.library_thread.stop_client()
|
self.library_thread.stop_client()
|
||||||
|
|
||||||
if self.monitor is not None:
|
if self.monitor is not None:
|
||||||
|
|
||||||
self.monitor.listener.stop()
|
self.monitor.listener.stop()
|
||||||
|
self.monitor.webservice.stop()
|
||||||
|
|
||||||
LOG.warn("---<<<[ %s ]", client.get_addon_name())
|
LOG.warn("---<<<[ %s ]", client.get_addon_name())
|
||||||
|
|
|
@ -18,6 +18,11 @@ def config():
|
||||||
logger.addHandler(LogHandler())
|
logger.addHandler(LogHandler())
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
def reset():
|
||||||
|
|
||||||
|
for handler in logging.getLogger('EMBY').handlers:
|
||||||
|
logging.getLogger('EMBY').removeHandler(handler)
|
||||||
|
|
||||||
|
|
||||||
class LogHandler(logging.StreamHandler):
|
class LogHandler(logging.StreamHandler):
|
||||||
|
|
||||||
|
|
36
service.py
36
service.py
|
@ -52,14 +52,18 @@ class ServiceManager(threading.Thread):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
service = None
|
||||||
service = Service()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
service = Service()
|
||||||
|
|
||||||
|
if DELAY and xbmc.Monitor().waitForAbort(DELAY):
|
||||||
|
raise Exception("Aborted during startup delay")
|
||||||
|
|
||||||
service.service()
|
service.service()
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
|
||||||
if not 'ExitService' in error:
|
if not 'ExitService' in error and service is not None:
|
||||||
service.shutdown()
|
service.shutdown()
|
||||||
|
|
||||||
self.exception = error
|
self.exception = error
|
||||||
|
@ -73,16 +77,36 @@ if __name__ == "__main__":
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if DELAY and xbmc.Monitor().waitForAbort(DELAY):
|
|
||||||
raise Exception("Aborted during startup delay")
|
|
||||||
|
|
||||||
session = ServiceManager()
|
session = ServiceManager()
|
||||||
session.start()
|
session.start()
|
||||||
session.join() # Block until the thread exits.
|
session.join() # Block until the thread exits.
|
||||||
|
|
||||||
if 'RestartService' in session.exception:
|
if 'RestartService' in session.exception:
|
||||||
|
|
||||||
|
''' Reload objects which depends on the patch module.
|
||||||
|
'''
|
||||||
LOG.warn("--[ RESTART ]")
|
LOG.warn("--[ RESTART ]")
|
||||||
|
|
||||||
|
import objects
|
||||||
|
import library
|
||||||
|
import full_sync
|
||||||
|
import monitor
|
||||||
|
|
||||||
|
reload_modules = ['objects.movies', 'objects.musicvideos', 'objects.tvshows',
|
||||||
|
'objects.music', 'objects.obj', 'objects.actions', 'objects.kodi.kodi',
|
||||||
|
'objects.kodi.movies', 'objects.kodi.musicvideos', 'objects.kodi.tvshows',
|
||||||
|
'objects.kodi.music', 'objects.kodi.artwork', 'objects.kodi.queries',
|
||||||
|
'objects.kodi.queries_music', 'objects.kodi.queries_texture']
|
||||||
|
|
||||||
|
for mod in reload_modules:
|
||||||
|
del sys.modules[mod]
|
||||||
|
|
||||||
|
reload(objects.kodi)
|
||||||
|
reload(objects)
|
||||||
|
reload(library)
|
||||||
|
reload(full_sync)
|
||||||
|
reload(monitor)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
|
Loading…
Reference in a new issue