Schedule job to check if server down

This commit is contained in:
Jonathan Wong 2015-11-16 23:19:59 -08:00
parent b28ac1543a
commit 4d87666a42
3 changed files with 36 additions and 1 deletions

View file

@ -20,6 +20,7 @@ import plexpy
import time
monitor_lock = threading.Lock()
ping_count = 0
def check_active_sessions(ws_request=False):
@ -219,3 +220,22 @@ def check_recently_added():
# Fire off notifications
threading.Thread(target=notification_handler.notify_timeline,
kwargs=dict(timeline_data=item, notify_action='created')).start()
def check_server_response():
with monitor_lock:
pms_connect = pmsconnect.PmsConnect()
response = pms_connect.get_server_response()
global ping_count
if not response:
ping_count += 1
logger.warn(u"PlexPy Monitor :: Unable to get a response from the server, ping attempt %s." % str(ping_count))
if ping_count == 3:
# Fire off notifications
threading.Thread(target=notification_handler.notify_timeline,
kwargs=dict(notify_action='down')).start()
else:
ping_count = 0