mirror of
https://github.com/skoelle/dyndns-updater.git
synced 2026-09-17 16:10:25 +00:00
Add SPEC, PLAN, Dockerfile, compose, env example, app modules, CI workflow
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import logging
|
||||
|
||||
import requests
|
||||
|
||||
log = logging.getLogger("healthcheck")
|
||||
|
||||
|
||||
def ping(ping_url: str, status: str = "success", message: str = ""):
|
||||
if not ping_url:
|
||||
log.debug("Kein HEALTHCHECK_PING_URL konfiguriert - Ping wird ausgelassen.")
|
||||
return
|
||||
|
||||
url = ping_url
|
||||
if status in ("fail", "partial-fail"):
|
||||
url = ping_url.rstrip("/") + "/fail"
|
||||
|
||||
body = message or status
|
||||
try:
|
||||
requests.post(url, data=body.encode("utf-8"), timeout=10)
|
||||
log.debug("Healthcheck-Ping gesendet (%s): %s", status, message)
|
||||
except requests.RequestException as exc:
|
||||
log.warning("Healthcheck-Ping fehlgeschlagen: %s", exc)
|
||||
Reference in New Issue
Block a user