feat: add Uptime Kuma integration with periodic ping task and configuration options

This commit is contained in:
Christian Krakau-Louis
2025-04-01 22:44:46 +02:00
parent 4ba34e2cbc
commit ceaed1a081
19 changed files with 921 additions and 525 deletions
+4
View File
@@ -68,6 +68,10 @@ def upload_to_sftp(file_path: str):
remote_base = settings.sftp_folder or ""
remote_path = extract_remote_path(file_path, settings.workdir, remote_base)
# Ensure the remote path starts with a slash if the base folder does
if remote_base.startswith('/') and not remote_path.startswith('/'):
remote_path = '/' + remote_path
# Function to check if file exists in SFTP server
def check_exists_in_sftp(path):
try:
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env python3
import logging
import requests
from celery import shared_task
from app.config import settings
logger = logging.getLogger(__name__)
@shared_task
def ping_uptime_kuma():
"""
Periodic Celery task that pings the configured Uptime Kuma URL
to report that the document processor service is running.
If no URL is configured, the task does nothing.
"""
if not settings.uptime_kuma_url:
logger.debug("Uptime Kuma URL not configured, skipping ping")
return
try:
logger.info(f"Pinging Uptime Kuma at {settings.uptime_kuma_url}")
response = requests.get(settings.uptime_kuma_url, timeout=10)
response.raise_for_status()
logger.info(f"Successfully pinged Uptime Kuma: {response.status_code}")
return True
except requests.exceptions.RequestException as e:
logger.error(f"Failed to ping Uptime Kuma: {e}")
return False