2012-06-08 34 views
4

這個問題讓我感到困惑,因爲我似乎在文檔內遵循所有可以進行平穩重啓的所有內容。在優雅的信號,nginx拋出嘗試連接到uWSGI套接字時拒絕連接

我在Emperor模式下運行uWSGI,有一堆封套。當我嘗試正常重啓其中一個封套時,我收到一個nginx 502 Bad Gateway響應大約半秒鐘。這裏的一些信息:

我的一個附庸.ini文件:

[uwsgi] 
master = true 
processes = 2 
home = /var/www/.virtualenvs/www.mysite.com 
socket = /tmp/uwsgi.sock.myapp 
pidfile = /tmp/uwsgi.pid.myapp 
module = myapp 
pythonpath = /var/www/www.mysite.com/mysite 
logto = /var/log/uwsgi/myapp.log 
chmod-socket = 666 
vacuum = true 
gid = www-data 
uid = www-data 

然後,我想平穩地重新啓動這一過程:

kill -HUP `cat /tmp/uwsgi.pid.myapp` 

從附庸日誌文件中的輸出看上去(我想?)

...gracefully killing workers... 
Gracefully killing worker 1 (pid: 29957)... 
Gracefully killing worker 2 (pid: 29958)... 
binary reloading uWSGI... 
chdir() to /var/www/www.mysite.com/vassals 
closing all non-uwsgi socket fds > 2 (max_fd = 1024)... 
found fd 3 mapped to socket 0 (/tmp/uwsgi.sock.kilroy) 
running /var/www/.virtualenvs/www.mysite.com/bin/uwsgi 
*** has_emperor mode detected (fd: 15) *** 
[uWSGI] getting INI configuration from kilroy.ini 
open("/var/log/uwsgi/kilroy.log"): Permission denied [utils.c line 250] 
unlink(): Operation not permitted [uwsgi.c line 998] 
*** Starting uWSGI 1.2.3 (64bit) on [Fri Jun 8 09:15:10 2012] *** 
compiled with version: 4.6.3 on 01 June 2012 09:56:19 
detected number of CPU cores: 2 
current working directory: /var/www/www.mysite.com/vassals 
writing pidfile to /tmp/uwsgi.pid.kilroy 
detected binary path: /var/www/.virtualenvs/www.mysite.com/bin/uwsgi 
setgid() to 33 
setuid() to 33 
your memory page size is 4096 bytes 
detected max file descriptor number: 1024 
lock engine: pthread robust mutexes 
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock.kilroy fd 3 
Python version: 2.7.3 (default, Apr 20 2012, 23:04:22) [GCC 4.6.3] 
Set PythonHome to /var/www/.virtualenvs/www.mysite.com 
*** Python threads support is disabled. You can enable it with --enable-threads *** 
Python main interpreter initialized at 0x19e3e90 
your server socket listen backlog is limited to 100 connections 
*** Operational MODE: preforking *** 
added /var/www/www.mysite.com/gapadventures/ to pythonpath. 
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x19e3e90 pid: 30041 (default app) 
*** uWSGI is running in multiple interpreter mode *** 
spawned uWSGI master process (pid: 30041) 
spawned uWSGI worker 1 (pid: 30042, cores: 1) 
spawned uWSGI worker 2 (pid: 30043, cores: 1) 

但是當我嘗試訪問該網站後,迅速後,我的nginx日誌ge ts這個結果:

2012/06/08 09:44:43 [error] 5885#0: *873 connect() to unix:///tmp/uwsgi.sock.kilroy failed (111: Connection refused) while connecting to upstream, client: 10.100.50.137, server: mydomain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock.kilroy:", host: "mydomain.com" 

這發生在發送信號約半秒後,所以這顯然不是很優雅。

有什麼建議嗎?非常感謝!

+0

遇到類似問題。目前的理論是,雖然uwsgi忙於重新加載,但它忽略/拒絕來自nginx的連接... – hwjp

回答

0

修正nginx config和uWSGI中的套接字路徑。 Sockt必須是相同的

當時

unix:///tmp/uwsgi.sock.kilroy 

/tmp/uwsgi.sock.myapp 

極品:

nginx的

unix:/tmp/uwsgi.sock.myapp 

uwsgi

socket = /tmp/uwsgi.sock.myapp 
相關問題