Răsfoiți Sursa

Merge branch 'cloudnative' of https://gitserver.reymota.es/creylopez/JugarAlPadelOC into cloudnative

Celestino Rey 5 luni în urmă
părinte
comite
96c9948498
3 a modificat fișierele cu 26 adăugiri și 11 ștergeri
  1. 1 1
      nginx/default.conf
  2. 23 8
      src/config/entrypoint.sh
  3. 2 2
      src/gestion_reservas/settings.py

+ 1 - 1
nginx/default.conf

@@ -22,7 +22,7 @@ server {
     }
 
     location /media/ {
-        alias /app/media/;
+        alias /app/mediafiles/;
     }
 
     error_page   500 502 503 504  /50x.html;

+ 23 - 8
src/config/entrypoint.sh

@@ -1,24 +1,39 @@
 #!/bin/bash
 RUN_PORT="8000"
 
-export PATH=/opt/venv/bin:$PATH
-
 if [ "$DATABASE" = "postgres" ]
 then
-    echo "Waiting for postgres..."
+    echo "Esperando a postgres..."
 
     while ! nc -z $SQL_HOST $SQL_PORT; do
       sleep 0.1
     done
 
-    echo "PostgreSQL started"
+    echo "PostgreSQL ha arrancado"
+
+	python manage.py migrate --no-input
+	python manage.py collectstatic --no-input
+
+	#/opt/venv/bin/gunicorn cartera_acciones.wsgi:application --bind "0.0.0.0:${RUN_PORT}" --daemon
+
+  # Start nginx as a daemon so it doesn't block, then run gunicorn in
+  # foreground (PID 1) so logs go to stdout/stderr and are visible to kubectl logs
+  nginx
 
-	/opt/venv/bin/python manage.py migrate --no-input
-	/opt/venv/bin/python manage.py collectstatic --no-input
+  # Determine log level
+  if [ "$DEBUG" = "True" ] || [ "$DEBUG" = "1" ]; then
+    LOG_LEVEL=debug
+  else
+    LOG_LEVEL=info
+  fi
 
-	/opt/venv/bin/gunicorn gestion_reservas.wsgi:application --bind "0.0.0.0:${RUN_PORT}" --daemon
+  echo "Lanzando gunicorn con log level: $LOG_LEVEL"
 
-	nginx -g 'daemon off;'
+  exec gunicorn gestion_reservas.wsgi:application \
+    --bind "0.0.0.0:${RUN_PORT}" \
+    --access-logfile - \
+    --error-logfile - \
+    --log-level "$LOG_LEVEL"
 else
     echo "la base de datos no es postgres: '$DATABASE'"
 fi

+ 2 - 2
src/gestion_reservas/settings.py

@@ -37,8 +37,8 @@ LOCAL = os.environ.get('LOCAL', 'False') == 'True'
 
 # hosts permitidos
 
-ALLOWED_HOSTS = [".ocp-cluster.reymota.lab", "*.rancher.lab", "jugaralpadel.es", ".reymota.es"]
-CSRF_TRUSTED_ORIGINS = ["https://*.ocp-cluster.reymota.lab", "http://jugaralpadel.rancher.reymota.lab", "https://jugaralpadel.rancher.reymota.lab", "https://jugaralpadel.es", "https://*.reymota.es"]
+ALLOWED_HOSTS = [".vmcluster.lab", "jugaralpadel.es", ".reymota.es"]
+CSRF_TRUSTED_ORIGINS = ["http://jugaralpadel.vmcluster.lab", "https://*.vmcluster.lab", "https://jugaralpadel.es", "https://*.reymota.es"]
 
 # Application definition