Skip to content

Commit

Permalink
Merge pull request #77 from forza-mor-rotterdam/develop
Browse files Browse the repository at this point in the history
develop -> main
  • Loading branch information
mguikema authored Jul 4, 2023
2 parents e74b6ef + 94d7e7a commit 10f993e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/apps/health/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class HealthConfig(AppConfig):
verbose_name = "Health"

def ready(self):
from apps.health.custom_checks import MeldingenAPIHealthCheck
from apps.health.custom_checks import MeldingenTokenCheck

plugin_dir.register(MeldingenAPIHealthCheck)
plugin_dir.register(MeldingenTokenCheck)
20 changes: 7 additions & 13 deletions app/apps/health/custom_checks.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import requests
from django.conf import settings
from apps.meldingen.utils import get_meldingen_token
from health_check.backends import BaseHealthCheckBackend
from health_check.exceptions import HealthCheckException


class MeldingenAPIHealthCheck(BaseHealthCheckBackend):
class MeldingenTokenCheck(BaseHealthCheckBackend):
critical_service = False

def check_status(self):
health_check_response = requests.get(settings.MELDINGEN_API_HEALTH_CHECK_URL)

if health_check_response.status_code != 200:
raise HealthCheckException(
f"Meldingen API not ready: status code: {health_check_response.status_code}"
)
if health_check_response.status_code == 404:
raise HealthCheckException(
f"Meldingen API: health url not implemented: status code: {health_check_response.status_code}"
)
try:
get_meldingen_token()
return "OK"
except Exception as e:
raise HealthCheckException(e)

def identifier(self):
return self.__class__.__name__
6 changes: 3 additions & 3 deletions docker-compose.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
app:
build: ./app
ports:
- "8010:8000"
- "8003:8000"
env_file:
- .env.test
volumes:
Expand All @@ -19,13 +19,13 @@ services:
networks:
- regie_network
ports:
- "7379:6379"
- "6379"

database:
image: postgis/postgis:11-3.3
shm_size: '1024m'
ports:
- "6432:5432"
- "5432"
env_file:
- .env.test
healthcheck:
Expand Down

0 comments on commit 10f993e

Please sign in to comment.