I'm trying to set up 2 Django web apps on the same machine using uWSGI emperor and nginx and have supervisord manage the starting and restarting of the emperor process. I have finally after a lot of searching on the internet managed to get a working deployment. However, during all the hair-pulling, I found something weird and I'd appreciate it if someone could explain to me why this is happening.
So I run my uWSGI process in emperor mode as root. The vassal ini config files take care of dropping privileges to my uid and creating a socket file owned by my user with the group as www-data (so that nginx can write to it) and permissions 660. Here is a sample vassal config:
[uwsgi] uid = xxxx chdir = %(project_dir)/%(project) home = %(venv_base)/%(venv) module = %(project).wsgi:application master = true processes = 4 socket = /tmp/%(project).sock chown-socket = %(uid):www-data chmod-socket = 660 stats = /tmp/%(project)_stat.sock logto = %(project_dir)/logs/uwsgi.log # Cleans up when the process is killed (includes deleting the socket file) vacuum = true
This works just fine but if I try to create the socket in /run instead of /tmp, I start getting permission denied errors for the socket bind() call. The socket is created just fine with the appropriate ownership and permissions but the vassal is unable to call bind() or unlink() on it. Why does this happen? What is the difference between /tmp and /run and when should I use them? Any help or pointers will be appreciated.
EDIT: I just tried setting the permissions of the socket to 777 and uwsgi still gives me a permission denied error :(