Moved from : https://stackoverflow.com/questions/25304968/uwsgi-django-with-nginx-high-availability-setup to here.
I was setting up High Availability on RHEL 6.5 . My Stack is
1. uwsgi
2. nginx
3. django
4. Pacemaker
Now I understand that nginx can be setup easily via monitoring the nginx_status
location /nginx_status {
# Turn on nginx stats
stub_status on;
access_log off;
# Security: Only allow access from 192.168.1.100 IP #
allow 127.0.0.1;
# Send rest of the world to /dev/null #
deny all;
}
This would ensure the heartbeat monitoring for nginx.
But, my question is how to ensure that uwsgi
would be in running state so that is when second nginx machine comes up it recognises the uwsgi
process and be bind to it. Or if the uwsgi
goes down, how to ensure to bring it up and rebind to nginx
The setup goes as follows
assuming cluster machines :
1. x.x.x.x (main machine)
2. y.y.y.y (slave machine)
Shared storage in
1. /apps (SAN)
/apps available in both the machines as shared storage
The application running django + uwsgi in
1. virtualenv : /apps/venv
2. applicaiton in : /apps
3. uwsgi configuration in : /apps/config.d
4. running application : /apps/project
uwsgi configuration
[uwsgi]
# the base directory (full path)
chdir = /apps/project
# Django's wsgi file
module = project.wsgi
# the virtualenv (full path)
home = /apps/venv
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 4
# the socket (use the full path to be safe
socket = /tmp/project.sock
# ... with appropriate permissions - may be needed
chmod-socket = 666
# clear environment on exit
vacuum = true
#daemonize
daemonize = true
#logging
logger = file:/tmp/uwsgi.log
I am not getting any idea about how uwsgi
would be running in HA setup ?