this will left production in ruins

This commit is contained in:
ITQ
2025-03-02 17:04:44 +03:00
parent c139f88a20
commit 9612b67721
15 changed files with 692 additions and 8 deletions
+2
View File
@@ -24,4 +24,6 @@ FROM docker.io/nginx:latest
COPY --from=builder /app/static /usr/share/nginx/html
COPY ../checker/checher_requirements.txt .
CMD ["nginx", "-g", "daemon off;"]
+4 -8
View File
@@ -7,7 +7,9 @@ from pathlib import Path
import django_stubs_ext
import environ
from health_check.plugins import plugin_dir
from django.utils.translation import gettext_lazy as _
from integrations.checker.healthcheck import CheckerHealthCheck
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -30,18 +32,12 @@ ALLOWED_HOSTS = env(
# Integrations
YANDEX_CLOUD_FOLDER_ID = env("YANDEX_CLOUD_FOLDER_ID", default=None)
YANDEX_CLOUD_API_KEY = env("YANDEX_CLOUD_API_KEY", default=None)
YANDEX_CLOUD_INTEGRATION_ENABLED = (
YANDEX_CLOUD_FOLDER_ID and YANDEX_CLOUD_API_KEY
)
CHECKER_API_ENDPOINT = env("CHECKER_API_ENDPOINT", default=None)
# Register healthchecks
# plugin_dir.register(SomeHealthCheckClass)
plugin_dir.register(CheckerHealthCheck)
# Caching
@@ -0,0 +1,22 @@
from http import HTTPStatus as status
import httpx
from django.conf import settings
from health_check.backends import BaseHealthCheckBackend
class CheckerHealthCheck(BaseHealthCheckBackend):
critical_service = False
def check_status(self) -> None:
try:
response = httpx.get(
f"{settings.ANTIFRAUD_ADDRESS}/ping", timeout=1
)
if response.status_code >= status.INTERNAL_SERVER_ERROR:
self.add_error("Checker service is unaccessible")
except httpx.HTTPError:
self.add_error("Checker service is unaccessible")
def identifier(self) -> str:
return self.__class__.__name__