0
votes

Currently using a django + uwsgi + nginx setup to server up a web - app. I am currently having trouble with respawning processes if they die due to poor python code in django.

Due to me being a poor coder, this happens a lot. I thought that uwsgi would just respawn a dead process.

My configuration files are as follows: for my UWSGI file:

[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

and my nginx file:

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;
}

I made init.d files for both nginx and uwsgi. I manage my uwsgi with emperor mode. Point it to a folder where I keep my uwsgi.ini file (its symlinked to /etc/uwsgi/vassals)

my UWSGI log is as follows: Please note the PID numbers: i start with 12363 and 12365, processes, get to a print message i do in my django code Why die here now and then I am left with only process 12363, and then it dies. and my web app refuses to load anything (that part makes sense)

[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)

I though uwsgi Emperor would respawn the vassal but the vassal isn't dead? I can restart everything, everything works fine for a bit...then die off.

1

1 Answers

1
votes

If a process dies you should see a message about its death in the logs. Are you sure your processes are not simply stuck ? You have enabled harakiri verbose, but not harakiri so there will no monitor for stuck requests.