2013-10-10 39 views
0

目前使用django + uwsgi + nginx設置來服務器啓動一個web應用程序。如果由於django中糟糕的python代碼而死亡,我目前在重新生成過程中遇到問題。uwsgi進程不重新生成

由於我是一個糟糕的編碼器,這發生了很多。我以爲uwsgi會重生一個死亡的過程。

我的配置文件如下: 我UWSGI文件:

[uwsgi] 
# variables 
projectname = testapp 
base = /home/ubuntu/testapp 
# config 
protocol = uwsgi 
pythonpath = %(base)/src/%(projectname) 
module = %(projectname).wsgi 
socket = /tmp/%(projectname).sock 
logto = %(base)/logs/uwsgi.log 

chmod-socket = 777 
processes = 2 
master = 1 
harakiri-verbose = true 

和我的nginx的文件:

server { 
    listen 80; 
    server_name mytestserver; 
    location/{ 
    include uwsgi_params; 
    uwsgi_read_timeout 300; 
    uwsgi_pass unix:///tmp/testapp.sock; 

    } 
    access_log /home/ubuntu/testapp/logs/access.log; 
    error_log /home/ubuntu/testapp/logs/error.log; 
} 

我做了兩個nginx的和uwsgi的init.d文件。 我用皇帝模式管理我的uwsgi。它指向哪裏我把我的uwsgi.ini文件(其符號鏈接到/ etc/uwsgi /附庸)文件夾

我UWSGI日誌如下: 請注意PID號:我開始與12363和12365,流程,在我的django代碼Why die here now中得到一條打印消息,然後我只剩下進程12363,然後死亡。和我的web應用程序拒絕加載任何東西(這部分是有道理的)

[pid: 12365|app: 0|req: 85/174] 123.123.123.123() {32 vars in 414 bytes} [Thu Oct 10 02:31:58 2013] POST /test1=> generated 9 bytes in 4 msecs (HTTP/1.1 200) 1 headers in 59 bytes (1 switches on core 0) 

[pid: 12365|app: 0|req: 86/175] 123.123.123.123() {32 vars in 414 bytes} [Thu Oct 10 02:31:58 2013] POST /test1 => generated 9 bytes in 3 msecs (HTTP/1.1 200) 1 headers in 59 bytes (1 switches on core 0) 

[pid: 12363|app: 0|req: 87/176] 123.123.123.123() {32 vars in 414 bytes} [Thu Oct 10 02:31:59 2013] POST /test1 => generated 9 bytes in 4 msecs (HTTP/1.1 200) 1 headers in 59 bytes (1 switches on core 0) 
why break here now? 

[pid: 12363|app: 0|req: 88/177] 123.123.123.123() {32 vars in 414 bytes} [Thu Oct 10 02:32:02 2013] POST /test1 => generated 9 bytes in 5 msecs (HTTP/1.1 200) 1 headers in 59 bytes (1 switches on core 0) 

[pid: 12363|app: 0|req: 89/178] 123.123.123.123() {32 vars in 414 bytes} [Thu Oct 10 02:32:02 2013] POST /test1 => generated 9 bytes in 7 msecs (HTTP/1.1 200) 1 headers in 59 bytes (1 switches on core 0) 

我雖然uwsgi皇帝會重生的附庸,但諸侯是不是死了嗎?我可以重新啓動一切,一切正常工作了一段時間...然後死掉。

回答

1

如果一個進程死了,你應該在日誌中看到關於它的死亡的消息。你確定你的流程不是簡單的卡住嗎?你已經啓用harakiri詳細,但不harakiri所以沒有監視器卡住的請求。

+0

有意思。所以我在我的uwsgi.ini中設置了harakiri = 10,並且它正在重新生成(我認爲)。以及我現在看到的事情正在死亡和重生。我收到了很多「HARAKIRI: - wchan> sk_wait_data」,這是超時消息。他們給我的「/usr/lib/libpython2.7.so.1.0(+0x5c86d一個回溯)0x7f495638486d] /usr/lib/libpython2.7.so.1.0(PyObject_Call+0x53)0x7f4956469053] /usr/lib/libpython2.7.so.1.0(+ 0x12539f)[0x7f495644d39f] ***結束回溯***「等等等等我怎麼理解呢? – user1639926

+0

您得到的上限是進程被阻止的系統調用。從你的日誌看來,你的進程看起來像你的進程在一個套接字上等待(很多時間)(可能是一個慢查詢或一個遠程服務器的api http事務?)。你也可以啓用python追溯程序(檢查uWSGI文檔),以便在harakiri期間獲得回溯。如果您在插座通信方面有不同的位置,找到中斷區域可能很有用 – roberto