Просмотр исходного кода

Corrijo llamada a gunicorn para que salgan los logs

creylopez 10 месяцев назад
Родитель
Сommit
38527c5351
1 измененных файлов с 21 добавлено и 7 удалено
  1. 21 7
      src/config/entrypoint.sh

+ 21 - 7
src/config/entrypoint.sh

@@ -1,27 +1,41 @@
 #!/bin/bash
 RUN_PORT="8000"
-#DATABASE=postgres
-#SQL_HOST=postgresql
-#SQL_PORT=5432
 
 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"
 
 	/opt/venv/bin/python manage.py migrate --no-input
 	/opt/venv/bin/python manage.py collectstatic --no-input
 
-	/opt/venv/bin/gunicorn misfinanzas.wsgi:application --bind "0.0.0.0:${RUN_PORT}" --daemon
+	#/opt/venv/bin/gunicorn cartera_acciones.wsgi:application --bind "0.0.0.0:${RUN_PORT}" --daemon
 
-	nginx -g 'daemon off;'
+  # 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
+
+  # Determine log level
+  if [ "$DEBUG" = "True" ] || [ "$DEBUG" = "1" ]; then
+    LOG_LEVEL=debug
+  else
+    LOG_LEVEL=info
+  fi
+
+  echo "Lanzando gunicorn con log level: $LOG_LEVEL"
+
+  exec /opt/venv/bin/gunicorn misfinanzas.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