Aggiunge task scheduler XML
This commit is contained in:
@@ -124,8 +124,8 @@ def migrate_config_data(data: dict[str, Any]) -> bool:
|
||||
if isinstance(server_check, dict) and int(server_check.get("port", 22)) == 22:
|
||||
server_check["port"] = 445
|
||||
changed = True
|
||||
if isinstance(server_check, dict) and int(server_check.get("interval_seconds", 300)) == 300:
|
||||
server_check["interval_seconds"] = 600
|
||||
if isinstance(server_check, dict) and int(server_check.get("interval_seconds", 300)) in {300, 600}:
|
||||
server_check["interval_seconds"] = 1800
|
||||
changed = True
|
||||
|
||||
destinations = backup.get("remote_destinations")
|
||||
|
||||
@@ -57,7 +57,7 @@ shutdown_command = "shutdown /s /t 0"
|
||||
[backup.server_check]
|
||||
type = "tcp"
|
||||
port = 445
|
||||
interval_seconds = 600
|
||||
interval_seconds = 1800
|
||||
timeout_seconds = 3
|
||||
|
||||
[stability]
|
||||
|
||||
@@ -2,14 +2,12 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from .config import AppConfig
|
||||
from .filters import WatchFilter
|
||||
from .logging_setup import close_logger
|
||||
from .registry import ChangeEvent, ChangeRegistry
|
||||
from .server_check import check_server, write_status
|
||||
|
||||
|
||||
class WatchdogRuntime:
|
||||
@@ -49,7 +47,7 @@ class WatchdogRuntime:
|
||||
observer.start()
|
||||
self.logger.info("BakRestWatchdog started")
|
||||
try:
|
||||
self._run_health_loop()
|
||||
self._run_service_loop()
|
||||
finally:
|
||||
observer.stop()
|
||||
observer.join(timeout=10)
|
||||
@@ -82,24 +80,9 @@ class WatchdogRuntime:
|
||||
self.registry.record(change)
|
||||
self.logger.info("Recorded %s: %s", event_type, target_path)
|
||||
|
||||
def _run_health_loop(self) -> None:
|
||||
interval = self.config.backup.server_check.interval_seconds
|
||||
self._publish_server_status()
|
||||
while not self.stop_event.wait(interval):
|
||||
self._publish_server_status()
|
||||
|
||||
def _publish_server_status(self) -> None:
|
||||
status = check_server(self.config.backup)
|
||||
pending_count = self.registry.pending_count()
|
||||
write_status(self.config.storage.status_file, status, pending_count)
|
||||
if status.reachable:
|
||||
self.logger.info("Backup server reachable; pending files: %s", pending_count)
|
||||
else:
|
||||
self.logger.warning(
|
||||
"Backup server unreachable: %s; pending files: %s",
|
||||
status.message,
|
||||
pending_count,
|
||||
)
|
||||
def _run_service_loop(self) -> None:
|
||||
while not self.stop_event.wait(60):
|
||||
pass
|
||||
|
||||
|
||||
def _safe_size(path: Path) -> int | None:
|
||||
|
||||
Reference in New Issue
Block a user