Hiya, I'm a bit new to uWSGI and running a python app with it.
My desired result:
- Use a version of python I control
- Install predictable dependencies using
- Not have to worry about constantly monitoring/restarting my application (i.e. starting a
screen session, running the process manually, instead relying on the crontab entry auto-generated by opalstack)
My attempted steps:
pyenv via basic github checkout ✅
pipenv, install dependencies into a virtualenv location (e.g.
- Configure uWSGI via:
-- set virtualenv line
virtualenv = /home/<opalstackuser>/.local/share/virtualenvs/<appname>-oaU6hgWW/
-- set module based on my flask app (I have
main.py which contains the
if __name__ == 'main.py, which I gather is unused) to
-- set touch-reload as per instructions here: https://help.opalstack.com/article/60/pythonuwsgi-applications
./stop && ./start
What I see in my
uWSGI http bound on 127.0.0.1:<port> fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:43212 (port auto-assigned) fd 3
Python version: 3.6.8 (default, Apr 2 2020, 13:34:55) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
PEP 405 virtualenv detected: /home/<opalstackuser>/.local/share/virtualenvs/<appname>-oaU6hgWW/
Set PythonHome to /home/<opalstackuser>/.local/share/virtualenvs/<appname>-oaU6hgWW/
Python main interpreter initialized at 0xfd03c0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 250128 bytes (244 KB) for 4 cores
*** Operational MODE: preforking+threaded ***
Traceback (most recent call last):
File "./<appname>/main.py", line 2, in <module>
from <dependency> import <RequiredClass>
ModuleNotFoundError: No module named '<dependency>'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 29587)
spawned uWSGI worker 1 (pid: 29588, cores: 2)
spawned uWSGI worker 2 (pid: 29589, cores: 2)
spawned uWSGI http 1 (pid: 29590)
Looking at this, it doesn't look like it's using my user's python is being used (not surprising, I haven't configured it and don't know where to), nor that it's using the correct dependencies? e.g. I can do
ls /home/<opalstackuser>/.local/share/virtualenvs/<appname>-oaU6hgWW/lib/python3.8/site-packages/ and see <dependency> as a folder in there.
Any tips on how to configure things from here?
I suppose I could just DIY an app listening on <port> but would prefer to stay close to the default Opalstack app setup.