add watchdog interval to settings

This commit is contained in:
dries.k
2022-02-01 20:50:22 +01:00
parent 83a94df246
commit 8731ad0747
2 changed files with 5 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
DEFAULT_SETTINGS = { DEFAULT_SETTINGS = {
"logging/level": "Disabled", "logging/level": "Disabled",
"tray/notifications/enabled": True,
"tray/notifications/priority": 5, "tray/notifications/priority": 5,
"tray/notifications/duration_ms": 5000, "tray/notifications/duration_ms": 5000,
"tray/notifications/icon/show": True, "tray/notifications/icon/show": True,
"watchdog/interval/s": 60,
} }

View File

@@ -5,12 +5,14 @@ import time
from PyQt6 import QtCore from PyQt6 import QtCore
from PyQt6.QtCore import pyqtSignal from PyQt6.QtCore import pyqtSignal
from gotify_tray.database import Settings
from gotify_tray.gotify.api import GotifyClient from gotify_tray.gotify.api import GotifyClient
from gotify_tray.gotify.models import GotifyVersionModel from gotify_tray.gotify.models import GotifyVersionModel
from . import gotify from . import gotify
settings = Settings("gotify-tray")
logger = logging.getLogger("gotify-tray") logger = logging.getLogger("gotify-tray")
@@ -105,13 +107,12 @@ class ServerConnectionWatchdogTask(BaseTask):
def __init__(self, gotify_client: GotifyClient): def __init__(self, gotify_client: GotifyClient):
super(ServerConnectionWatchdogTask, self).__init__() super(ServerConnectionWatchdogTask, self).__init__()
self.gotify_client = gotify_client self.gotify_client = gotify_client
self.interval = 60
def task(self): def task(self):
while True: while True:
time.sleep(self.interval) time.sleep(settings.value("watchdog/interval/s", type=int))
if not self.gotify_client.is_listening(): if not self.gotify_client.is_listening():
self.closed.emit() self.closed.emit()
logger.debug( logger.debug(
f"ServerConnectionWatchdogTask: gotify_client is not listening" "ServerConnectionWatchdogTask: gotify_client is not listening"
) )