Nginx and uwsgi; different ports

nginxpythonuwsgi

I have Nginx and two python virtual environments with uwsgi. These environments are for dev and production. What I want is to run production on :80 and dev on :6544 ports

Here's the config I have

server {
    listen          80;
    access_log      off;
    error_log       /var/log/nginx/http.prod.error.log;

    charset         utf-8;
    location / {
        uwsgi_pass  unix:///tmp/uwsgi.sock;
        include     uwsgi_params;
    }

}    

server {
    listen          6544;
    access_log      off;
    error_log       /var/log/nginx/http.dev.error.log;

    charset         utf-8;
    location / {
        uwsgi_pass  unix:///tmp/uwsgi.sock;
        include     uwsgi_params;
    }

}

When I do %production%/bin/uwsgi --ini-paste-logged %production%/production.ini
it runs well. But when I'm trying to start dev version %dev%/bin/uwsgi --ini-paste-logged %dev%/dev.ini I got the next in the uwsgi.log:

*** Starting uWSGI 1.9.12 (64bit) on [Fri Jun  7 07:35:21 2013] ***
compiled with version: 4.4.3 on 07 June 2013 07:32:32
os: Linux-2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012
nodename: pt-apps2
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 24
current working directory: /home/dev
writing pidfile to ./pid_5000.pid
detected binary path: /home/dev/bin/uwsgi
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
unlink(): Operation not permitted [core/socket.c line 135]
bind(): Address already in use [core/socket.c line 185]
*** Starting uWSGI 1.9.12 (64bit) on [Fri Jun  7 07:38:24 2013] ***
compiled with version: 4.4.3 on 07 June 2013 07:32:32
os: Linux-2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012
nodename: pt-apps2
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 24
current working directory: /home/dev
writing pidfile to ./pid_5000.pid
detected binary path: /home/dev/bin/uwsgi
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
unlink(): Operation not permitted [core/socket.c line 135]
bind(): Address already in use [core/socket.c line 185]

dev.ini contains the next settings:

[uwsgi]
socket = /tmp/uwsgi.sock
master = true

processes = 4

harakiri = 60
harakiri-verbose = true
limit-post = 65536
post-buffering = 8192

daemonize = ./uwsgi.log
pidfile = ./pid_5000.pid

listen = 256

max-requests = 1000

reload-on-as = 128
reload-on-rss = 96
no-orphans = true

log-slow = true

I believe I did something wrong with the config, but I have no idea what is wrong.
Another interesting stuff, when production UWSGI is running, I can access to :6544 but I don't see dev version there, only production. So I think that 80 and 6544 ports are used for production only. Any idea how I can split two versions of one app by the ports?

Thanks

Best Answer

You're trying to use the same Unix domain socket for both dev and production. Use different sockets for them.