I am trying to run this code
uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data
I am following this tutorial. But I am getting the below output.
*** Starting uWSGI 2.0.11.2 (64bit) on [Thu Nov 5 04:42:12 2015] ***
compiled with version: 4.8.4 on 04 November 2015 16:32:43
os: Linux-3.16.0-52-generic #71~14.04.1-Ubuntu SMP Fri Oct 23 17:24:53 UTC 2015
nodename: myproject
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /var/www/myproject
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
setgid() to 33
setuid() to 33
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 15305
your memory page size is 4096 bytes
detected max file descriptor number: 1024
*** starting uWSGI Emperor ***
This is my .ini file
plugins = python
chdir = /var/www/myproject/
module = myproject.wsgi:application
home = /var/www/
master = true
processes = 10
socket = /var/www/myproject/uwsgi.sock
chmod-socket = 666
vacuum = true
My code is working with this
uwsgi --ini myproject.ini
Please help me to solve this puzzle thank you.
It seems to work fine! Did you try connecting nginx? You can ignore the warnings now.
Related
The issue here is that everything is configured, and runs without error, and yet I do not know why it is not working. As you'll see I get no app can't load error, I get no errors at all, in fact it's the most complete without errors I've had since I started. And yet, 500 response. Alot of this is here for completeness as I'll explain. If I take emperor out of the mix, it works, just fine.
I have been trying to deploy an opensource flask app ceph-dash for monitoring via uwsgi/nginx. I succeeded eventually albeit painfully. I have written a gist about my success https://gist.github.com/Lighiche/a6aec14166d62b4f8f013415a2c1f757
Howver, since there's no daemon management and the likes I thought it best to add to what I've done by using uwsgi emperor and I followed this guide to the letter
https://chriswarrick.com/blog/2016/02/10/deploying-python-web-apps-with-nginx-and-uwsgi-emperor/
I am on Centos 7. I have successful run and tested the app on this implementation as you can see in the gist, I actually went out of my way to discover how to configure uwsgi under different scenarios.
However with the emperor implementation of wsgi and all it's config files. I am getting a 500 response internal server error. And I think it's to do with the hand off between nginx and emperor or emperor itself. As when I stop the uwsgi service I get a 502. So nginx at least sees the socket file.
WSGI server start log, all green
*** Starting uWSGI 2.0.13.1 (64bit) on [Thu Sep 1 11:16:24 2016] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-4) on 02 August 2016 21:07:54
os: Linux-3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016
nodename: prdceph-mon00
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /etc/uwsgi.d
detected binary path: /usr/sbin/uwsgi
chdir() to /etc/nginx/sites-enabled/ceph-dash
your processes number limit is 7282
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/run/uwsgi/ceph-dash.sock fd 6
Python version: 2.7.5 (default, Aug 18 2016, 15:58:25) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
Python main interpreter initialized at 0xee1030
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 363840 bytes (355 KB) for 4 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0xee1030 pid: 3236 (default app)
mountpoint already configured. skip.
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 3236)
spawned uWSGI worker 1 (pid: 3241, cores: 1)
spawned uWSGI worker 2 (pid: 3242, cores: 1)
spawned uWSGI worker 3 (pid: 3243, cores: 1)
spawned uWSGI worker 4 (pid: 3244, cores: 1)
[pid: 3243|app: 0|req: 1/1] 127.0.0.1 () {34 vars in 429 bytes} [Thu Sep 1 11:17:31 2016] GET / => generated 291 bytes in 77 msecs (HTTP/1.1 500) 2 headers in 84 bytes (1 switches on core 0)
announcing my loyalty to the Emperor...
WSGI service start log, all green
uwsgi.service - uWSGI Emperor Service
Loaded: loaded (/usr/lib/systemd/system/uwsgi.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2016-09-01 11:16:24 BST; 2s ago
Process: 3231 ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi (code=exited, status=0/SUCCESS)
Process: 3229 ExecStartPre=/bin/mkdir -p /run/uwsgi (code=exited, status=0/SUCCESS)
Main PID: 3234 (uwsgi)
Status: "The Emperor is governing 1 vassals"
CGroup: /system.slice/uwsgi.service
├─3234 /usr/sbin/uwsgi --ini /etc/uwsgi.ini
├─3235 /usr/sbin/uwsgi --ini /etc/uwsgi.ini
├─3236 /usr/sbin/uwsgi --ini cephdash.ini
├─3241 /usr/sbin/uwsgi --ini cephdash.ini
├─3242 /usr/sbin/uwsgi --ini cephdash.ini
├─3243 /usr/sbin/uwsgi --ini cephdash.ini
└─3244 /usr/sbin/uwsgi --ini cephdash.ini
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: thunder lock: disabled (you can enable it with --thunder-lock)
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: your mercy for graceful operations on workers is 60 seconds
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: *** Operational MODE: no-workers ***
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: spawned uWSGI master process (pid: 3234)
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: *** Stats server enabled on /run/uwsgi/stats.sock fd: 7 ***
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: *** starting uWSGI Emperor ***
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: *** has_emperor mode detected (fd: 7) ***
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: [uWSGI] getting INI configuration from cephdash.ini
Sep 01 11:16:25 prdceph-mon00 uwsgi[3234]: Thu Sep 1 11:16:25 2016 - [emperor] vassal cephdash.ini has been spawned
Sep 01 11:16:25 prdceph-mon00 uwsgi[3234]: Thu Sep 1 11:16:25 2016 - [emperor] vassal cephdash.ini is ready to accept requests
WSGI server response 500
[pid: 3243|app: 0|req: 1/1] 127.0.0.1 () {34 vars in 429 bytes} [Thu Sep 1 11:17:31 2016] GET / => generated 291 bytes in 77 msecs (HTTP/1.1 500) 2 headers in 84 bytes (1 switches on core 0)
NGINX server response 500
<ip> - - [01/Sep/2016:11:14:16 +0100] "GET / HTTP/1.1" 500 291 "http://<ip>/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" "<my ip>, <ip>"
127.0.0.1 - - [01/Sep/2016:11:17:31 +0100] "GET / HTTP/1.1" 500 291 "-" "Python-urllib/2.7"
cat /etc/uwsgi.ini
[uwsgi]
uid = uwsgi
gid = nginx
pidfile = /run/uwsgi/uwsgi.pid
emperor = /etc/uwsgi.d
stats = /run/uwsgi/stats.sock
#emperor-tyrant = true
cap = setgid,setuid
cat /etc/uwsgi.d/cephdash.ini (this is a symlink to the wsgi.ini for the app)
[uwsgi]
chdir = /etc/nginx/sites-enabled/ceph-dash
wsgi-file = /etc/nginx/sites-enabled/ceph-dash/contrib/wsgi/cephdash.wsgi
module = ceph-dash:app
enable-threads = true
master = true
processes = 4
socket = /var/run/uwsgi/ceph-dash.sock
chmod-socket = 777
vacuum = true
uid = uwsgi
gid = nginx
daemonize = /tmp/ceph-dash.log
plugins = python,logfile
logger = file:/tmp/myappuwsgi.log
cat /etc/nginx/conf.d/cephdash.conf
upstream uwsgi {
server unix:///var/run/uwsgi/ceph-dash.sock;
}
server {
listen 5000;
server_name <hostname>
charset utf-8;
location / {
uwsgi_pass uwsgi;
include /etc/nginx/sites-enabled/ceph-dash/contrib/nginx/uwsgi_params;
}
}
I have uninstalled the uwsgi that I installed via pip. I appear still to have a /sbin/uwsgi (linked from /usr/sbin) which looks to be the one installed for systemd and a /usr/bin/uwsgi I don't know how that happened. I changed the .service file to use /usr/bin and have the same error. However the binary from the rpm does not have the plugsin installed and the one in /usr/bin does. systemd uwsgi now starts with /usr/bin/uwsgi and as you can see below that binary loads the plugins required but I get the same internal server error, and the same messaged from systemd and startup logs no errors, no failures. Just a 500.
rpm -ql uwsgi
/etc/uwsgi.d
/etc/uwsgi.ini
/run/uwsgi
/usr/lib/systemd/system/uwsgi.service
/usr/sbin/uwsgi
/usr/share/doc/uwsgi-2.0.13.1
/usr/share/doc/uwsgi-2.0.13.1/CHANGELOG
/usr/share/doc/uwsgi-2.0.13.1/README
/usr/share/doc/uwsgi-2.0.13.1/README.Fedora
/usr/share/licenses/uwsgi-2.0.13.1
/usr/share/licenses/uwsgi-2.0.13.1/LICENSE
python --version
Python 2.7.5
uwsgi --version
2.0.13.1
which uwsgi (POINTING TO THE RIGHT PLACE but systemd is now loading /usr/bin)
/sbin/uwsgi
uwsgi --plugins-list (DOES NOT SHOW THE PLUGINS LOADED)
*** uWSGI loaded generic plugins ***
corerouter
*** uWSGI loaded request plugins ***
100: ping
101: echo
--- end of plugins list ---
*** Starting uWSGI 2.0.13.1 (64bit) on [Thu Sep 8 09:58:40 2016] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-4) on 02 August 2016 21:07:54
os: Linux-3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016
nodename: prdceph-mon00
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /tmp
detected binary path: /usr/sbin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7282
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
The -s/--socket option is missing and stdin is not a socket.
/usr/bin/uwsgi --plugins-list
DOES SHOW THE PLUGINS LOADED
*** uWSGI loaded generic plugins ***
gevent
nagios
rrdtool
carbon
corerouter
fastrouter
http
ugreen
syslog
rsyslog
logsocket
router_uwsgi
router_redirect
router_basicauth
zergpool
redislog
mongodblog
router_rewrite
router_http
logfile
router_cache
rawrouter
router_static
sslrouter
cheaper_busyness
transformation_tofile
transformation_gzip
transformation_chunked
transformation_offload
router_memcached
router_redis
router_hash
router_expires
router_metrics
transformation_template
stats_pusher_socket
*** uWSGI loaded request plugins ***
0: python
17: spooler
18: symcall
100: ping
110: signal
111: cache
173: rpc
--- end of plugins list ---
*** Starting uWSGI 2.0.13.1 (64bit) on [Thu Sep 8 09:58:50 2016] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-4) on 29 August 2016 09:55:26
os: Linux-3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016
nodename: prdceph-mon00
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /tmp
detected binary path: /usr/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7282
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
The -s/--socket option is missing and
uWSGI installed by yum and by pip are different. Systemd will probably use one installed by yum. When you're SSH'ing and running uWSGI by yourself, system will use one installed by pip by default.
Main difference between that uWSGI versions is: lack of python support in one installed by yum, because it tends to be modular. You can install it, probably by using yum install uwsgi-python (check your distribution repositories for specific package name). Be aware that different python plugins are needed for different python versions (2.7 will require different plugin than 3.5) and adjust package name to be installed accordingly.
After installation of python plugin check that's plugin name (visible for uWSGI) and adjust value in plugins in your .ini file. That name will probably match installed package name without uwsgi- prefix.
For me, I tried to restart nginx but it kept giving an error. I found the problem to be an extra .conf file in sitesavailable folder.
I changed my uWSGI setup to use the Emperor for multi-app deployment. With the old setup when loading 'mypasswords.pwds' file which was saved right next to my app, there was no issue.
Now running everything with the Emperor I get 'No such file or direcotry' errors. This might be because of my setup or because the Emperor simply works in a different way and I'm not sure what's the case.
Directory Tree:
Project
thisismyapp.py
passwords.pwds
Config for uWSGI Emperor:
[uwsgi]
# Variables
base = /var/www/Project
# Generic Config
home = %(base)/venv
pythonpath = %(base)
socket = /tmp/%n.sock
module = thisismyapp:app # Is this an issue?
logto = /var/log/uwsgi/%n.log
Traceback:
*** Starting uWSGI 2.0.11.2 (64bit) on [Thu Feb 4 00:41:47 2016] ***
compiled with version: 4.9.2 on 24 October 2015 23:42:32
os: Linux-3.19.0-42-generic #48-Ubuntu SMP Thu Dec 17 22:54:45 UTC 2015
nodename: website
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /etc/uwsgi/apps-enabled
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 1868
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/project.sock fd 3
Python version: 2.7.9 (default, Apr 2 2015, 15:37:21) [GCC 4.9.2]
Set PythonHome to /var/www/Project/venv
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x17355e0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145520 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
added /var/www/Project/ to pythonpath.
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x17355e0 pid: 6772 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 6772)
spawned uWSGI worker 1 (pid: 6779, cores: 1)
[pid: 6779|app: 0|req: 1/1] 79.227.145.119 () {46 vars in 967 bytes} [Thu Feb 4 00:41:51 2016] GET / => generated 3552 bytes in 355 msecs (HTTP/1.1 200) 2 headers in 81 bytes (1 switches on core 0)
announcing my loyalty to the Emperor...
[Errno 2] No such file or directory: 'passwords.pwds'
Python file access:
f = open('passwords.pwds', 'r')
Try this one:
from os import path
passwords_location = path.join(path.dirname(path.realpath(__file__), 'passwords.pwds'))
with open(passwords_location) as f:
do_something()
Your original way using the relative location, so may can't find the file if you're not in the Project folder. Also, use with block is a better way to handle files, it will ensure to close the file when exit the context block.
I'm trying to run a Flask application using a ubuntu 12.04 server with nginx and uWSGI however after starting the server, specifying the wsgi.ini file and then starting nginx, I try to access the page but I get a 502 bad gateway error with nginx. I know that it is an issue with the flask application and uWSGI. I checked the uWSGI logs and found this:
*** Starting uWSGI 2.0.11.1 (64bit) on [Thu Sep 17 19:38:03 2015] ***
compiled with version: 4.8.4 on 17 September 2015 15:58:04
os: Linux-3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015
nodename: ip-172-31-30-153
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/ubuntu/myapp
writing pidfile to /home/ubuntu/myapp/myapp.pid
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7862
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:5000 fd 3
Python version: 2.7.6 (default, Jun 22 2015, 18:01:27) [GCC 4.8.2]
Set PythonHome to /home/ubuntu/myapp
ImportError: No module named site
I found this question's top answer but saw received the same error. If it is something to do with PYTHONHOME, I'm following this guide and it states:
The $PYTHONPATH variable seems to get unset randomly, and causes
errors for later steps. To avoid this, add the following line to the
top of your ~/.bashrc file:
export
PYTHONPATH='/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/PILcompat'
So what could be the issue? Is it PYTHONHOME or another factor affecting it? Thanks.
Edit:
My uwsgi.ini:
[uwsgi]
home = /home/ubuntu/myapp
wsgi-file = %(home)/run.py
socket = 127.0.0.1:5000
callable = app
module = app
pythonpath = %(home)
daemonize = %(home)/myapp.log
pidfile = %(home)/myapp.pid
To run it, I use uwsgi uwsgi.ini.
I am having trouble getting my flask app to run on a new server running CentOS 6.5.using uWSGI. (I have a similar CentOS box that it runs fine on)
I installed uWSGI within a virtual environment. I was getting the following error (in stdout) when calling uwsgi binary from the virtualenv
$ /path/to/venv/bin/uwsgi --emperor /etc/uwsgi/vassals
*** Starting uWSGI 2.0.8 (64bit) on [Mon Nov 17 21:18:13 2014] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-11) on 16 November 2014 22:19:09
os: Linux-2.6.32-431.1.2.0.1.el6.x86_64 #1 SMP Fri Dec 13 13:06:13 UTC 2013
nodename: boxname
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/username
detected binary path: /home/username/mydevelopment/venvs/ecodev_do/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 1024
your memory page size is 4096 bytes
detected max file descriptor number: 1024
*** starting uWSGI Emperor ***
*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from ers_portal_uwsgi.ini
Mon Nov 17 21:18:14 2014 - [emperor] curse the uwsgi instance ers_portal_uwsgi.ini (pid: 22724)
Mon Nov 17 21:18:17 2014 - [emperor] removed uwsgi instance ers_portal_uwsgi.ini
The uwsgi.log file shows:
*** Starting uWSGI 2.0.8 (64bit) on [Mon Nov 17 21:25:40 2014] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-11) on 16 November 2014 22:19:09
os: Linux-2.6.32-431.1.2.0.1.el6.x86_64 #1 SMP Fri Dec 13 13:06:13 UTC 2013
nodename: boxname
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /etc/uwsgi/vassals
detected binary path: /home/username/mydevelopment/venvs/ecodev_do/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /home/username/mydevelopment/git/ers_portal
your processes number limit is 1024
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /home/username/mydevelopment/git/ers_portal/ers_portal_uwsgi.sock fd 3
Python version: 2.7.8 (default, Nov 12 2014, 23:36:57) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
Set PythonHome to /home/username/mydevelopment/venvs/ecovapor_dev
ImportError: No module named site
Then, reading the official uWSGI documentation they describe a scenario where uwsgi is installed in a venv, but then it has to be installed system-wide after that. So, I used
pip2.7 install uwsgi (which created the binary in /usr/local/bin/uwsgi)
I have tried all of the following with no change in the error or the output (with and without venv activated)..
$ /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals
$ /home/username/mydevelopment/venvs/ecodev_do/bin/uwsgi --emperor /etc/uwsgi/vassals
$ /home/username/mydevelopment/venvs/ecodev_do/bin/uwsgi --no-site
--emperor /etc/uwsgi/vassals
$ uwsgi --emperor /etc/uwsgi/vassals
$ uwsgi --no-site --emperor /etc/uwsgi/vassals
$ /path/to/venv/bin/uwsgi ~/mydevelopment/git/ers_portal/ers_portal_uwsgi.ini (the .ini file is symlinked in /etc/uwsgi/vassals )
Here is emperor.ini;
[uwsgi]
emperor = /etc/uwsgi/vassals
uid = username
gid = username
logto = /home/username/mydevelopment/git/ers_portal/logs/uwsgiEmperor.log
Here is ers_portal_uwsgi.ini;
[uwsgi]
master = true
#user info
uid = username
gid = username
#application's base folder
base = /home/username/mydevelopment/git/ers_portal
#chdir to this folder when starting
chdir = /home/username/mydevelopment/git/ers_portal
#python module to import
app = run_web
module = %(app)
home = /home/username/mydevelopment/venvs/ecovapor_dev
pythonpath = %(base)
#socket file's location
socket = /home/username/mydevelopment/git/ers_portal/%n.sock
#permissions for the socket file
chmod-socket = 666
#the variable that holds a flask application inside the module imported at line #6
#uwsgi varible only, does not relate to your flask application
callable = app
#location of log files
logto = /home/username/mydevelopment/git/ers_portal/logs/%n.log
This helped me.
Type it in your terminal.
unset PYTHONHOME
unset PYTHONPATH
In case someone uses python 3.x, installing uwsgi with pip3 solved this problem for me:
sudo pip3 install uwsgi
The virtualenv in question and uwsgi must be using the same python version.
In case you want to use multiple python versions on the same system, you can get the uwsgi source and follow the instructions here: http://projects.unbit.it/uwsgi/wiki/MultiPython
Then add a "plugin=/path/to/plugin" to the .ini file
Take note that plugins dont work for the packaged Ubuntu versions (built monolithic), but you need to compile the source directly for a fully modular binary
I have been trying to read everything I can find concerning this issue (and have learned much while doing so). The closest link I could find is here and here. My issue is almost identical except I'm running uwsgi exclusively in emperor mode. When I run uswsgi services WITHOUT running it in emperor mode my django website runs just fine. No matter how I change my configuration I always get the error message my /tmp/uwsgi.log file: "--- no python application found, check your startup logs for errors ---" I have listed my configuration and error log below:
OS version: Linux raspberrypi 3.6.11+ #538 armv6l GNU/Linux
Django version: 1.6.5
uwsgi version: 2.0.5.1
Virtual environment: /var/www/testbed/env
Project location: /var/www/testbed/project/auth
project tree:
./auth/
|-- __init__.py
|-- __init__.pyc
|-- requirements.txt
|-- settings.py
|-- settings.pyc
|-- urls.py
|-- urls.pyc
|-- wsgi.py
`-- wsgi.pyc
file wsgi.py:
"""
WSGI config for auth project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
import os, sys, site
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")))
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
sys.path.append('/usr/lib/python2.7')
sys.path.append('/usr/lib/python2.7/dist-packages')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "auth.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
file /etc/uwsgi/emperor.ini:
[uwsgi]
master = true
emperor = /etc/uwsgi/vassals
logto = /tmp/uwsgi.log
file /etc/uwsgi/vessals/auth.ini:
[uwsgi]
#plugins = python
# Django-related settings
chdir =/var/www/testbed/project/auth
module = auth.wsgi:application
# the virtualenv (full path)
home =/var/www/testbed/env
virtualenv =/var/www/testbed/env
# process-related settings
enable-threads = true
pythonpath = /var/www/testbed/project/auth
#wsgi-file = /var/www/testbed/project/auth/auth/wsgi.py
env = DJANGO_SETTINGS_MODULE=auth.settings
mount = /testbed/auth/admin=/var/www/testbed/project/auth/auth/wsgi.py
manage-script-name = true
#route-run = log:SCRIPT_NAME=${SCRIPT_NAME}
# maximum number of worker processes
processes = 1 #Simple rule is # of cores on machine
# the socket (use the full path to be safe
socket = /var/www/testbed/project/auth/uwsgi.sock
# ... with appropriate permissions - may be needed
chmod-socket = 664
# clear environment on exit
vacuum = true
logto = /tmp/uwsgi.log
Command being executed listed below:
/var/www/testbed/env/bin/uwsgi --ini /etc/uwsgi/emperor.ini --emperor /etc/uwsgi/vassals/ --http :8000 --plugin python --binary-pathusr/local/bin/uwsgi
Error file /tmp/uwsgi.log:
*** Starting uWSGI 2.0.5.1 (32bit) on [Tue Jun 10 19:06:12 2014] ***
compiled with version: 4.6.3 on 10 June 2014 01:41:52
os: Linux-3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013
nodename: raspberrypi
machine: armv6l
clock source: unix
detected number of CPU cores: 1
current working directory: /etc/uwsgi
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your processes number limit is 3376
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 6
*** starting uWSGI Emperor ***
uwsgi socket 0 bound to TCP address 127.0.0.1:57524 (port auto-assigned) fd 5
Python version: 2.7.3 (default, Mar 18 2014, 05:13:23) [GCC 4.6.3]
*** has_emperor mode detected (fd: 8) ***
[uWSGI] getting INI configuration from auth.ini
*** Starting uWSGI 2.0.5.1 (32bit) on [Tue Jun 10 19:06:12 2014] ***
compiled with version: 4.6.3 on 09 June 2014 23:07:00
os: Linux-3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013
nodename: raspberrypi
machine: armv6l
clock source: unix
detected number of CPU cores: 1
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your processes number limit is 3376
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/www/testbed/project/auth/uwsgi.sock fd 3
Python version: 2.7.3 (default, Mar 18 2014, 05:13:23) [GCC 4.6.3]
Set PythonHome to /var/www/testbed/env
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1dca830
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 128512 bytes (125 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 23068)
spawned uWSGI worker 1 (pid: 23071, cores: 1)
spawned uWSGI http 1 (pid: 23072)
Python main interpreter initialized at 0x616918
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 128512 bytes (125 KB) for 1 cores
*** Operational MODE: single process ***
added /var/www/testbed/project/auth/ to pythonpath.
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x616918 pid: 23070 (default app)
mounting /var/www/testbed/project/auth/auth/wsgi.py on /testbed/auth/admin
added /var/www/testbed/project/auth/ to pythonpath.
WSGI app 1 (mountpoint='/testbed/auth/admin') ready in 3 seconds on interpreter 0x9c6218 pid: 23070
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 23070)
Tue Jun 10 19:06:18 2014 - [emperor] vassal auth.ini has been spawned
spawned uWSGI worker 1 (pid: 23073, cores: 1)
Tue Jun 10 19:06:18 2014 - [emperor] vassal auth.ini is ready to accept requests
--- no python application found, check your startup logs for errors ---
[pid: 23071|app: -1|req: -1/1] 192.168.1.6 () {38 vars in 742 bytes} [Tue Jun 10 19:07:11 2014] GET /testbed/auth/admin => generated 21 bytes in 1 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 23071|app: -1|req: -1/2] 192.168.1.6 () {36 vars in 626 bytes} [Tue Jun 10 19:07:11 2014] GET /favicon.ico => generated 21 bytes in 1 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 23071|app: -1|req: -1/3] 192.168.1.6 () {38 vars in 742 bytes} [Tue Jun 10 19:07:13 2014] GET /testbed/auth/admin => generated 21 bytes in 2 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 23071|app: -1|req: -1/4] 192.168.1.6 () {36 vars in 626 bytes} [Tue Jun 10 19:07:13 2014] GET /favicon.ico => generated 21 bytes in 1 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
At this point, I'm grasping at straws. Out of all the reading that I have done I can't see why this keeps rendering the "Internal Server Error." I may have over looked something that why I've finally given in to my pride by posting my sorrows here. Since I've gotten this far I really do think that I have overlooked something very small. Any help would be greatly appreciated.
I had this issue several times in my deployments with usgi-emperor an the problem was that I didn't set the correct ALLOWED_HOSTS in my Django's project config file
In your config you shold have
ALLOWED_HOSTS=[ "yourdomain.com", "other.domain.com" ]
or this (discouraged because of security concerns, use at your own risk):
ALLOWED_HOSTS=["*"]
to allow any host
https://docs.djangoproject.com/en/1.8/ref/settings/#allowed-hosts