If your OpenLiteSpeed setup is pointed to the wsgi.py file in python it can be confusing when changes made in your local python app won't update as expected when changes are pulled to your website or pushed. Graceful (from OLS Backend), Soft & Hard (from Linux command line) OLS server resets won't always result in old wsgi processes being stopped and new ones created. Often I've had to completely reboot the server to ensure changes are made.
This is especially perplexing as these changes can brick your setup resulting in 400 and 500 errors that are difficult to troubleshoot because of the wsgi structure. A common instance for this to occur is when the settings.py file is modified. Locally "python manage.py runserver" and even a locally hosted wsgi test can show your changes working correctly, but the server still won't function as expected.
The solution I've found is to search for and kill wsgi processes that can be identified by the location of your wsgi.py file:
Running this in bash will help you identify the wsgy processes that need killed:
A tool to monitor processes running on your Linux system:
regex formatted search string:
identifies processes owned by lsadm (OLS admin server) in the folder structure /project/app/wsgi.py:
You'll need to adjust the project/app/wsgi.py folder scheme to match the pattern where you wsgi.py file is located. The server will initiate wsgi.py processes as needed to host your website. To kill these processes, identify the process number (1234, will never be the same) and then run:
For a one-line kill all processes run this after you have modified project/app to match the location of your wsgi.py file
The nice thing about OLS is on the next server request to your website, new wsgi.py processes will be automatically be fired upon request after the old wsgi.py processes are killed. You won't have to soft or hard reset to see your changes.
Here is some additional information you may find useful concerning this issue:
modwsgi.readthedocs.io/en/master/user-guides/reloading-source-code.html
From what I can tell OLS runs in EMBEDDED MODE and isn't able to rest easily without killing these processes. Maybe someone has a better procedure?
This is especially perplexing as these changes can brick your setup resulting in 400 and 500 errors that are difficult to troubleshoot because of the wsgi structure. A common instance for this to occur is when the settings.py file is modified. Locally "python manage.py runserver" and even a locally hosted wsgi test can show your changes working correctly, but the server still won't function as expected.
The solution I've found is to search for and kill wsgi processes that can be identified by the location of your wsgi.py file:
Running this in bash will help you identify the wsgy processes that need killed:
Code:
ps aux | grep -E '^lsadm.*/project\/app\/wsgi.py'
Code:
ps aux
Code:
grep -E
Code:
^lsadm.*/project\/app\/wsgi.py
Code:
sudo kill 1234
Code:
sudo kill $(ps aux | grep -E '^lsadm.*/project\/app\/wsgi.py' | awk '{print $2}')
Here is some additional information you may find useful concerning this issue:
modwsgi.readthedocs.io/en/master/user-guides/reloading-source-code.html
From what I can tell OLS runs in EMBEDDED MODE and isn't able to rest easily without killing these processes. Maybe someone has a better procedure?
Last edited: