Add the /healthcheck path which returns an HTTP200 OK response for checking the helath of the container after startup
This commit is contained in:
parent
a59fad4866
commit
561b2aed27
@ -1,5 +1,5 @@
|
||||
FROM alpine:latest
|
||||
RUN apk add --no-cache python3 py3-pip python3-dev py3-setuptools gcc python3-dev jpeg-dev zlib-dev musl-dev py3-gunicorn
|
||||
RUN apk add --no-cache python3 py3-pip python3-dev py3-setuptools gcc python3-dev jpeg-dev zlib-dev musl-dev py3-gunicorn curl
|
||||
COPY . /home/shimatta/kenkyusho
|
||||
WORKDIR /home/shimatta/kenkyusho
|
||||
RUN python3 -m venv /home/shimatta/kenkyusho/.venv && . /home/shimatta/kenkyusho/.venv/bin/activate && pip install -r requirements.txt
|
||||
|
@ -22,6 +22,12 @@ services:
|
||||
depends_on:
|
||||
shimatta-kenkyusho-db:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -f localhost:8000/healthcheck"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
|
||||
shimatta-kenkyusho-db:
|
||||
image: postgres:16.5-alpine
|
||||
|
@ -16,4 +16,5 @@ urlpatterns = [
|
||||
path('distributors/<slug:uuid>/', parts_views.DistributorDetailView.as_view(), name='parts-distributors-detail'),
|
||||
path('manufacturers/', parts_views.ManufacturersViewSet.as_view(), name='parts-manufacturers'),
|
||||
path("manufacturers/<slug:uuid>/", parts_views.ManufacturerDetailViewSet.as_view(), name='parts-manufacturers-detail'),
|
||||
path("healthcheck/", parts_views.health_check_view, name='parts-health-check'),
|
||||
]
|
||||
|
@ -18,8 +18,10 @@ from .forms import *
|
||||
from django.db.models import Q
|
||||
from django.db.models.functions import Lower
|
||||
from django.forms import formset_factory
|
||||
from django.http import HttpResponse
|
||||
import uuid
|
||||
|
||||
|
||||
ParameterSearchFormSet = formset_factory(ComponentParameterSearchForm, extra=1)
|
||||
|
||||
class QrSearchForm(forms.Form):
|
||||
@ -954,3 +956,11 @@ class ManufacturerDetailViewSet(LoginRequiredMixin, BaseTemplateMixin, DetailVie
|
||||
return self.edit_manufacturer(request)
|
||||
|
||||
return super().post(request, *args, **kwargs)
|
||||
|
||||
|
||||
def health_check_view(request) -> HttpResponse:
|
||||
"""
|
||||
Health checking view. Returns empty http response with HTTP status OK.
|
||||
This will be used to check
|
||||
"""
|
||||
return HttpResponse(status=200)
|
Loading…
Reference in New Issue
Block a user