fix(deploy): use /ready/ healthcheck and /srv/mnemosyne path
All checks were successful
CVE Scan & Docker Build / security-scan (push) Successful in 1m9s
CVE Scan & Docker Build / build-and-push (push) Successful in 2m31s

- Change app healthcheck from /live/ to /ready/ to verify full
  readiness including dependencies (DB, Neo4j, S3)
- Increase healthcheck timeout from 5s to 10s to accommodate
  dependency checks
- Add S3 bucket connectivity check to readiness probe
- Update deployment documentation to use /srv/mnemosyne instead
  of /opt/mnemosyne as the compose project directory
This commit is contained in:
2026-05-04 09:23:36 -04:00
parent de0d7a4317
commit cbe7921938
3 changed files with 40 additions and 13 deletions

View File

@@ -52,6 +52,30 @@ def live(request):
return JsonResponse({"status": "ok"})
def _check_s3() -> str | None:
"""Return an error string if the Mnemosyne S3 bucket is unreachable, else None."""
import boto3
import botocore.exceptions
from django.conf import settings
try:
client = boto3.client(
"s3",
endpoint_url=settings.AWS_S3_ENDPOINT_URL or None,
aws_access_key_id=settings.AWS_ACCESS_KEY_ID or None,
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY or None,
region_name=settings.AWS_S3_REGION_NAME or None,
use_ssl=getattr(settings, "AWS_S3_USE_SSL", True),
verify=getattr(settings, "AWS_S3_VERIFY", True),
)
client.head_bucket(Bucket=settings.AWS_STORAGE_BUCKET_NAME)
return None
except botocore.exceptions.ClientError as e:
return f"HTTP {e.response['Error']['Code']}"
except Exception as e:
return str(e)
def ready(request):
errors = {}
try:
@@ -62,6 +86,9 @@ def ready(request):
cache.get("__readiness_probe__")
except Exception as e:
errors["cache"] = str(e)
s3_error = _check_s3()
if s3_error:
errors["s3"] = s3_error
if errors:
return JsonResponse({"status": "error", "errors": errors}, status=503)
return JsonResponse({"status": "ok"})