mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-22 11:23:02 +00:00
da99b8b034
* add simple health endpoint * add curl and healthcheck to dockerfile * convert to view * add simple test * Add unhealthy test * Cleanup * check for LD_SERVER_PORT env var in healthcheck def * Revert changes to middlewares.py Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@gmail.com>
20 lines
433 B
Python
20 lines
433 B
Python
from django.db import connections
|
|
from django.http import JsonResponse
|
|
|
|
from bookmarks.views.settings import app_version
|
|
|
|
|
|
def health(request):
|
|
code = 200
|
|
response = {
|
|
'version': app_version,
|
|
'status': 'healthy'
|
|
}
|
|
|
|
try:
|
|
connections['default'].ensure_connection()
|
|
except Exception:
|
|
response['status'] = 'unhealthy'
|
|
code = 500
|
|
|
|
return JsonResponse(response, status=code)
|