Notas de Luis

¡Esta es una revisión vieja del documento!


Nivel superior

Flask - 3 - Troubleshooting

Introduction

Tutorial de Desarrollo de una Aplicación con Flask y Gestión con systemd

Referencias: Flask mega tutorial

Troubleshooting

Here are some troubleshooting steps… For when things do not go right there are a few things you can do to troubleshoot.

It is very important to check carefully for any spelling errors in all the files you edited.

Check systemd.

$ sudo systemctl status my_flask_app.service
$ sudo journalctl -xe

Restart the Gunicorn systemd service.

$ sudo systemctl restart my_flask_app.service
$ sudo systemctl daemon-reload

Add logging to Gunicorn by changing the ExecStart line. Add –error-logfile error.log and –log-level debug to the end of the line.

Cambia la linea ExecStart (todo en la misma línea):

ExecStart=/var/www/my_flask_app/.venv/bin/gunicorn --workers 3 
  --bind unix:/var/www/my_flask_app/myproject.sock wsgi:app

a esto (todo en la misma línea):

ExecStart=/var/www/my_flask_app/.venv/bin/gunicorn --workers 3 
  --bind unix:/var/www/my_flask_app/myproject.sock wsgi:app 
  --error-logfile error.log --log-level debug

Check the Nginx log files.

$ less /var/log/nginx/error.log
$ less /var/log/nginx/my_flask_app.error.log

Comprobar si nginx está escuchando en el puerto 80.

$ ss -lnt | grep 80
LISTEN    0         511                0.0.0.0:80               0.0.0.0:* 
LISTEN    0         511                   [::]:80                  [::]:* 

Usa curl para comprobar que da una respuesta 200 OK.

$ curl -I http://my_flask_app

Salida esperada (aproximada):

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 30
Server: gunicorn/21.2.0
Date: Wed, 03 Feb 2021 15:18:55 GMT
computing/web/flask_app_3.1768382279.txt.gz · Última modificación: por alfabeto