reef-technologies / cookiecutter-rt-django

CookieCutter template for Django application projects with docker-compose etc.
BSD 3-Clause "New" or "Revised" License
19 stars 24 forks source link

Healthcheck endpoint #174

Closed adal-chiriliuc-reef closed 7 months ago

adal-chiriliuc-reef commented 7 months ago

Added /healthcheck endpoint.

It's enabled if cookiecutter.monitoring is set. Should I always enable it, or create a new cookiecutter.healthcheck env?

Checks postgres, redis and django orm. Returns 200 or 500 status code with status json:

// HTTP 200
{
  "time": "2024-04-11 09:29:07.199961+00:00",
  "postgres_ok": true,
  "redis_ok": true,
  "orm_ok": true,
  "all_ok": true
}
// HTTP 500
{
  "time": "2024-04-11 09:29:07.199961+00:00",
  "postgres_ok": true,
  "redis_ok": false,
  "redis_error": "ConnectionError('Error 111 connecting to localhost:8379. Connection refused.')",
  "orm_ok": true,
  "all_ok": false
}
// HTTP 500
{
  "time": "2024-04-11 09:29:07.199961+00:00",
  "postgres_ok": true,
  "redis_ok": true,
  "orm_ok": false,
  "orm_error": "ProgrammingError('relation \"healthcheck_model\" does not exist\\nLINE 1: DELETE FROM \"healthcheck_model\"\\n                    ^\\n')",
  "all_ok": false
}
mjurbanski-reef commented 7 months ago

why not https://github.com/revsys/django-health-check ?

adal-chiriliuc-reef commented 7 months ago

I looked at that lib, even took some inspiration from it.

Seemed a bit heavy, I will check it again in more detail.

mjurbanski-reef commented 7 months ago

@adal-chiriliuc-reef unless there is some strong argument against it, let's not reinvent the wheel here and use what seems to be quite popular solution for this problem. That solution would be in line with our tenets https://github.com/reef-technologies/handbook/tree/master?tab=readme-ov-file#what-does-high-performance-mean .

adal-chiriliuc-reef commented 7 months ago

Ok, I will switch to using the library

adal-chiriliuc-reef commented 7 months ago

will create new PR