500 502, and general checklist - Torniojaws/vortech-backend GitHub Wiki

If you start to get 500/502 from it, go through these first:

  1. The first thing to check is the uWSGI log: /srv/vortech-backend/uwsgi.log and check for errors
  2. Make sure the file html/settings/secret.cfg exists and has correct values (defined in Ansible vault)

If uWSGI logs say something like "Cannot import/find Flask", might need to do these steps:

  1. Make sure Python 3.6+ is installed and default update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
  2. Make sure uWSGI uses Python 3.6+
wget https://projects.unbit.it/downloads/uwsgi-latest.tar.gz
tar -xvzf uwsgi-latest.tar.gz

mv uwsgi-2.0.17 uwsgi
cd uwsgi
make PROFILE=nolang # no language defaults allows flexibility for python versions

PYTHON=python3.6 # or --> PYTHON=/usr/bin/python3.6

./uwsgi --build-plugin "plugins/python python36"
mv python36_plugin.so plugins/python
cd ..
sudo mv uwsgi /usr/local
sudo ln -s /usr/local/uwsgi/uwsgi /usr/local/bin/uwsgi

Then, you can use it in configuration files as follows:

[uwsgi]
plugins-dir = /usr/local/uwsgi/plugins/python
plugin = python36