Flush temporary sessions automatically if failed to check sessions on startup

This commit is contained in:
JonnyWong16 2018-03-19 23:24:09 -07:00
parent e3b71a729e
commit a5807f21b4
2 changed files with 11 additions and 4 deletions

View file

@ -293,8 +293,8 @@ def connect_server(log=True, startup=False):
try: try:
web_socket.start_thread() web_socket.start_thread()
except: except Exception as e:
logger.error(u"Websocket :: Unable to open connection.") logger.error(u"Websocket :: Unable to open connection: %s." % e)
def check_server_access(): def check_server_access():

View file

@ -25,6 +25,7 @@ import plexpy
import activity_handler import activity_handler
import activity_pinger import activity_pinger
import activity_processor import activity_processor
import database
import logger import logger
name = 'websocket' name = 'websocket'
@ -33,8 +34,14 @@ ws_shutdown = False
def start_thread(): def start_thread():
# Check for any existing sessions on start up try:
activity_pinger.check_active_sessions(ws_request=True) # Check for any existing sessions on start up
activity_pinger.check_active_sessions(ws_request=True)
except Exception as e:
logger.error(u"Tautulli WebSocket :: Failed to check for active sessions: %s." % e)
logger.warn(u"Tautulli WebSocket :: Attempt to fix by flushing temporary sessions...")
database.delete_sessions()
# Start the websocket listener on it's own thread # Start the websocket listener on it's own thread
thread = threading.Thread(target=run) thread = threading.Thread(target=run)
thread.daemon = True thread.daemon = True