mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-20 13:23:24 -07:00
Fix server up/down status on Tautulli startup
This commit is contained in:
parent
64d67d8209
commit
8447663e27
2 changed files with 11 additions and 6 deletions
|
@ -93,7 +93,7 @@ HTTP_ROOT = None
|
||||||
DEV = False
|
DEV = False
|
||||||
|
|
||||||
WS_CONNECTED = False
|
WS_CONNECTED = False
|
||||||
PLEX_SERVER_UP = True
|
PLEX_SERVER_UP = None
|
||||||
|
|
||||||
|
|
||||||
def initialize(config_file):
|
def initialize(config_file):
|
||||||
|
|
|
@ -41,6 +41,9 @@ def start_thread():
|
||||||
|
|
||||||
|
|
||||||
def on_connect():
|
def on_connect():
|
||||||
|
if plexpy.PLEX_SERVER_UP is None:
|
||||||
|
plexpy.PLEX_SERVER_UP = True
|
||||||
|
|
||||||
if not plexpy.PLEX_SERVER_UP:
|
if not plexpy.PLEX_SERVER_UP:
|
||||||
logger.info(u"Tautulli WebSocket :: The Plex Media Server is back up.")
|
logger.info(u"Tautulli WebSocket :: The Plex Media Server is back up.")
|
||||||
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intup'})
|
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intup'})
|
||||||
|
@ -49,8 +52,11 @@ def on_connect():
|
||||||
plexpy.initialize_scheduler()
|
plexpy.initialize_scheduler()
|
||||||
|
|
||||||
|
|
||||||
def on_disconnect(ws_exception=False):
|
def on_disconnect():
|
||||||
if not ws_exception and plexpy.PLEX_SERVER_UP:
|
if plexpy.PLEX_SERVER_UP is None:
|
||||||
|
plexpy.PLEX_SERVER_UP = False
|
||||||
|
|
||||||
|
if plexpy.PLEX_SERVER_UP:
|
||||||
logger.info(u"Tautulli WebSocket :: Unable to get a response from the server, Plex server is down.")
|
logger.info(u"Tautulli WebSocket :: Unable to get a response from the server, Plex server is down.")
|
||||||
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intdown'})
|
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intdown'})
|
||||||
plexpy.PLEX_SERVER_UP = False
|
plexpy.PLEX_SERVER_UP = False
|
||||||
|
@ -86,7 +92,6 @@ def run():
|
||||||
global ws_reconnect
|
global ws_reconnect
|
||||||
ws_reconnect = False
|
ws_reconnect = False
|
||||||
reconnects = 0
|
reconnects = 0
|
||||||
ws_exception = False
|
|
||||||
|
|
||||||
# Try an open the websocket connection
|
# Try an open the websocket connection
|
||||||
while not plexpy.WS_CONNECTED and reconnects < plexpy.CONFIG.WEBSOCKET_CONNECTION_ATTEMPTS:
|
while not plexpy.WS_CONNECTED and reconnects < plexpy.CONFIG.WEBSOCKET_CONNECTION_ATTEMPTS:
|
||||||
|
@ -143,8 +148,8 @@ def run():
|
||||||
|
|
||||||
except (websocket.WebSocketException, Exception) as e:
|
except (websocket.WebSocketException, Exception) as e:
|
||||||
logger.error(u"Tautulli WebSocket :: %s." % e)
|
logger.error(u"Tautulli WebSocket :: %s." % e)
|
||||||
|
ws.shutdown()
|
||||||
plexpy.WS_CONNECTED = False
|
plexpy.WS_CONNECTED = False
|
||||||
ws_exception = True
|
|
||||||
break
|
break
|
||||||
|
|
||||||
# Check if we recieved a restart notification and close websocket connection cleanly
|
# Check if we recieved a restart notification and close websocket connection cleanly
|
||||||
|
@ -156,7 +161,7 @@ def run():
|
||||||
|
|
||||||
if not plexpy.WS_CONNECTED and not ws_reconnect:
|
if not plexpy.WS_CONNECTED and not ws_reconnect:
|
||||||
logger.error(u"Tautulli WebSocket :: Connection unavailable.")
|
logger.error(u"Tautulli WebSocket :: Connection unavailable.")
|
||||||
on_disconnect(ws_exception)
|
on_disconnect()
|
||||||
|
|
||||||
logger.debug(u"Tautulli WebSocket :: Leaving thread.")
|
logger.debug(u"Tautulli WebSocket :: Leaving thread.")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue