• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Solved Start uwsgi at system boot

Farhan Khan

Member

Thanks: 6
Messages: 89

#1
I am trying to build a VM "appliance" that will be running uwsgi/Django. This uses a python virtualenv, so uwsgi only starts when within that virtualenv. When I try to run it outside of a virtualenv, I get this error:

Code:
$ uwsgi config.ini
[uWSGI] getting INI configuration from config.ini
*** Starting uWSGI 2.0.15 (64bit) on [Sun Jul 23 09:23:10 2017] ***
compiled with version: 4.2.1 Compatible FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564) on 29 June 2017 06:51:11
os: FreeBSD-11.1-RC1 FreeBSD 11.1-RC1 #0 r320486: Fri Jun 30 02:25:16 UTC 2017     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC
nodename: axial
machine: amd64
clock source: unix
detected number of CPU cores: 1
current working directory: /usr/home/axial/axial
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 5734
your memory page size is 4096 bytes
detected max file descriptor number: 28467
lock engine: POSIX semaphores
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
Python version: 2.7.13 (default, Jun 29 2017, 01:17:13)  [GCC 4.2.1 Compatible FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564)]
Set PythonHome to /usr/home/axial/venv/
ImportError: No module named site
Within the virtualenv, I have the 'site' module installed, but it still fails.

Is there a way to run uwsgi when outside of a virtualenv? If not, is there a way to initialize a virtualenv from within the startup script only for the script?

My very simple config.ini is as follows:

Code:
[uwsgi]
socket = 127.0.0.1:3031
wsgi-file = /usr/home/user/axial/axial/wsgi.py
workers = 1
virtualenv = /usr/home/user/venv/
pythonpath = /usr/home/user/venv/bin/python3
 

Farhan Khan

Member

Thanks: 6
Messages: 89

#2
Figured it out. uwsgi from the packages is for python2, not python3.
You have to recompile it from the ports.
I set the following in /etc/make.conf:
Code:
PYTHON_VERSION=python3.6
PYTHON_VERSION_MINIMUM=3.6
DEFAULT_VERSIONS=python=python3.6 python2=2.7 python3=3.6
Then I did cd /usr/ports/www/uwsgi && make install clean and it worked!
 

tobik@

Daemon
Developer

Thanks: 1,336
Messages: 1,908

#4
Indeed. Thanks to the recent changes you don't even have to build uwsgi from ports now to use it with Python 3.6. Just pkg install uwsgi-py36 will do.
 
Top