fix: resolve gunicorn app import and systemd permission issues

This commit is contained in:
2026-09-04 22:20:34 -03:00
parent 9b6678724c
commit e0c58409cd
2 changed files with 16 additions and 4 deletions
+16 -4
View File
@@ -30,7 +30,18 @@ LOG_DIR="/var/log/${SERVICE_NAME}"
# ─── Root check ──────────────────────────────────────────────────────────────── # ─── Root check ────────────────────────────────────────────────────────────────
[[ $EUID -ne 0 ]] && err "Ejecutá este script con sudo: sudo bash install.sh" [[ $EUID -ne 0 ]] && err "Ejecutá este script con sudo: sudo bash install.sh"
[[ ! -f "${APP_DIR}/app.py" ]] && err "No se encontró app.py en ${APP_DIR}. ¿Estás en el directorio correcto?"
# Si el directorio está dentro de /root, lo movemos a /opt para evitar problemas de permisos
if [[ "${APP_DIR}" == /root/* ]]; then
NEW_DIR="/opt/admin-edu-space"
warn "Detectado directorio en ${APP_DIR}. Moviendo a ${NEW_DIR} para evitar errores de permisos..."
mkdir -p /opt
mv "${APP_DIR}" "${NEW_DIR}"
cd "${NEW_DIR}"
exec bash install.sh
fi
[[ ! -f "${APP_DIR}/wsgi.py" ]] && err "No se encontró wsgi.py en ${APP_DIR}. ¿Estás en el directorio correcto?"
echo -e "\n${BOLD}${CYAN}" echo -e "\n${BOLD}${CYAN}"
echo "╔══════════════════════════════════════════════════════════════╗" echo "╔══════════════════════════════════════════════════════════════╗"
@@ -120,7 +131,7 @@ else
# Admin Edu-Space — Configuración de producción # Admin Edu-Space — Configuración de producción
# Generado automáticamente el $(date '+%Y-%m-%d %H:%M:%S') # Generado automáticamente el $(date '+%Y-%m-%d %H:%M:%S')
FLASK_APP=app.py FLASK_APP=wsgi.py
FLASK_ENV=production FLASK_ENV=production
SECRET_KEY=${SECRET_KEY} SECRET_KEY=${SECRET_KEY}
@@ -207,7 +218,7 @@ else
LC_ALL=en_US.UTF-8 \ LC_ALL=en_US.UTF-8 \
PYTHONUTF8=1 \ PYTHONUTF8=1 \
PYTHONIOENCODING=utf-8 \ PYTHONIOENCODING=utf-8 \
FLASK_APP=app.py \ FLASK_APP=wsgi.py \
"${VENV_DIR}/bin/python" -X utf8 init_db.py "${VENV_DIR}/bin/python" -X utf8 init_db.py
ok "Esquema, roles, edificios y usuario admin inicializados" ok "Esquema, roles, edificios y usuario admin inicializados"
@@ -254,6 +265,7 @@ Environment="LC_ALL=en_US.UTF-8"
Environment="PYTHONUTF8=1" Environment="PYTHONUTF8=1"
Environment="PYTHONIOENCODING=utf-8" Environment="PYTHONIOENCODING=utf-8"
Environment="FLASK_ENV=production" Environment="FLASK_ENV=production"
Environment="HOME=${APP_DIR}"
ExecStart=${GUNICORN_BIN} \ ExecStart=${GUNICORN_BIN} \
--workers 3 \ --workers 3 \
--bind 0.0.0.0:5000 \ --bind 0.0.0.0:5000 \
@@ -261,7 +273,7 @@ ExecStart=${GUNICORN_BIN} \
--access-logfile ${LOG_DIR}/access.log \ --access-logfile ${LOG_DIR}/access.log \
--error-logfile ${LOG_DIR}/error.log \ --error-logfile ${LOG_DIR}/error.log \
--log-level info \ --log-level info \
app:app wsgi:app
Restart=always Restart=always
RestartSec=5 RestartSec=5
StandardOutput=journal StandardOutput=journal
View File