Add healthcheck for Spotify proxy

This commit is contained in:
Jake Howard 2023-08-19 13:00:01 +01:00
parent 96a6ded02e
commit 0541f6ce22
Signed by: jake
GPG Key ID: 57AFB45680EDD477
2 changed files with 24 additions and 0 deletions

11
website/spotify/apps.py Normal file
View File

@ -0,0 +1,11 @@
from django.apps import AppConfig
from health_check.plugins import plugin_dir
class SpotifyAppConfig(AppConfig):
name = "website.spotify"
def ready(self) -> None:
from .healthchecks import SpotifyHealthCheckBackend
plugin_dir.register(SpotifyHealthCheckBackend)

View File

@ -0,0 +1,13 @@
import requests
from django.conf import settings
from health_check.backends import BaseHealthCheckBackend
class SpotifyHealthCheckBackend(BaseHealthCheckBackend):
def check_status(self) -> None:
requests.get(
f"https://{settings.SPOTIFY_PROXY_HOST}/.health/"
).raise_for_status()
def identifier(self) -> str:
return "Spotify Proxy"