I have a django project currently running with the following configuration:
I installed Python 3.6.1 from source and created a new virtual environment with python 3.6 (I use virtualenvwrapper), but I seem to have some trouble getting the project to start up with uwsgi.
Config file is as follows:
[uwsgi]
plugins = python3
project = %n
module = myapp.wsgi:application
home = path_to_new_env
socket = /var/run/uwsgi-%n.sock
chdir = path_to_new_env/myapp/myapp
processes = 4
max-requests = 5000
chmod-socket = 666
chown-socket = user:user
master = True
vacuum = True
logto = /var/log/%n_LOG.log
buffer-size = 32768
I was under the impression that the python3
plugin would include support for python 3.6, but the log indicates that the Python 3.4.x interpreter is still being used.
In my list of installed uwsgi plugins, I see support for python 2, 3 and 3.4 but nothing more. I'm not sure what needs to be done to have the correct interpreter set on startup.
Any advice would be appreciated.
UPDATE: I've tried building a uwsgi plugin for python 3.6:
root@app:~# PYTHON=python3.6 uwsgi --build-plugin "/root/uwsgi-2.0.15/plugins/python python36"
*** uWSGI building and linking plugin from /root/uwsgi-2.0.15/plugins/python ***
[gcc -pthread] python36_plugin.so
/root/uwsgi-2.0.15/plugins/python/python_plugin.c: In function ‘uwsgi_python_atexit’:
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:380:11: error: ‘struct uwsgi_server’ has no member named ‘skip_atexit_teardown’
if (uwsgi.skip_atexit_teardown)
^
/root/uwsgi-2.0.15/plugins/python/python_plugin.c: At top level:
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:2018:2: error: unknown field ‘worker’ specified in initializer
.worker = uwsgi_python_worker,
^
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:2018:2: error: initialization from incompatible pointer type [-Werror]
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:2018:2: error: (near initialization for ‘python36_plugin.exception_class’) [-Werror]
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:2018:2: error: initialized field overwritten [-Werror=override-init]
/root/uwsgi-2.0.15/plugins/python/python_plugin.c:2018:2: error: (near initialization for ‘python36_plugin.exception_class’) [-Werror=override-init]
cc1: all warnings being treated as errors
/root/uwsgi-2.0.15/plugins/python/uwsgi_pymodule.c: In function ‘py_uwsgi_spooler_get_task’:
/root/uwsgi-2.0.15/plugins/python/uwsgi_pymodule.c:2107:2: error: implicit declaration of function ‘uwsgi_spooler_read_header’ [-Werror=implicit-function-declaration]
if (uwsgi_spooler_read_header(task_path, spool_fd, &uh) ||
^
/root/uwsgi-2.0.15/plugins/python/uwsgi_pymodule.c:2108:3: error: implicit declaration of function ‘uwsgi_spooler_read_content’ [-Werror=implicit-function-declaration]
uwsgi_spooler_read_content(spool_fd, spool_buf, &body, &body_len, &uh, &task_stat)) {
^
cc1: all warnings being treated as errors
*** unable to build python36 plugin ***
uWSGI presents a complete stack for networked/clustered web applications, implementing message/object passing, caching, RPC and process management. It is designed to be fully modular.
Nginx is “a web server which can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache”. uWSGI is an implementation of the WSGI spec, which describes how a web server should communicate with a web app, which makes uWSGI also a type of web server.
Preface¶ In both Ubuntu 18.04 (Bionic Beaver) and 18.10 (Cosmic Cuttlefish) the uWSGI plugin for Python 3 use the default version 3.6 . It's possible to compile an uWSGI plugin using the official Python 3.7 package, and we will see how to do it step by step.
uWSGI is often used in conjunction with web servers such as Cherokee and Nginx, which offer direct support for uWSGI's native uwsgi protocol, to serve Python web applications such as Django. For example, data may flow like this: HTTP client ↔ Nginx ↔ uWSGI ↔ Python app. A common alternative to uWSGI is Gunicorn.
I've recently came up with a solution to python3.6 apps with uwsgi server.
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
Mimic this process for any other python version you'd like to have available on the uwsgi server.
More help here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With