Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions aviso_core/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
if request.path.rstrip("/") == "/gbm/health":
return self.get_response(request)

# ===========================================================
# 1. REQUEST PHASE: Initialize Context
# ===========================================================
Expand Down
32 changes: 23 additions & 9 deletions aviso_core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@

DEBUG = os.environ.get('DEBUG', 'True') == 'True'
# --- LOGIC FOR ALLOWED HOSTS ---
if DEBUG:
# Local development
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0']
CSRF_TRUSTED_ORIGINS = ["http://localhost:8000", "http://127.0.0.1:8000"]
else:
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',')
trusted_origins = os.environ.get('TRUSTED_ORIGINS', '').split(',')
CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in trusted_origins if origin.strip()]

# Application definition
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',')
trusted_origins = os.environ.get('TRUSTED_ORIGINS', '').split(',')
CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in trusted_origins if origin.strip()]

INSTALLED_APPS = [
'django.contrib.admin',
Expand Down Expand Up @@ -89,6 +83,26 @@
}


# if DEBUG:
# DATABASES = {
# "default": {
# "ENGINE": "django.db.backends.sqlite3",
# "NAME": BASE_DIR / "db.sqlite3",
# }
# }
# else:
# DATABASES = {
# "default": {
# "ENGINE": "django.db.backends.postgresql",
# "NAME": os.environ.get("DB_NAME"),
# "USER": os.environ.get("DB_USER"),
# "PASSWORD": os.environ.get("DB_PASSWORD"),
# "HOST": os.environ.get("DB_HOST"),
# "PORT": os.environ.get("DB_PORT", "5432"),
# }
# }


# Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators

Expand Down
6 changes: 3 additions & 3 deletions gbm_apis/api/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.views import View
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.db import connection
# from django.db import connection
from django.conf import settings

logger = logging.getLogger(f'gnana.{__name__}')
Expand All @@ -26,8 +26,8 @@ def get(self, request):

try:
## TODO Mongo HEalth CHeck
with connection.cursor() as cursor:
cursor.execute("SELECT 1")
# with connection.cursor() as cursor:
# cursor.execute("SELECT 1")
health_status["checks"]["database"] = "ok"
except Exception as db_error:
logger.warning(f"Database health check failed: {str(db_error)}")
Expand Down