benoitc/gunicorn — Issue #291: gunicorn process fails to stop and locks port preventing restart
Author: fredpalmer
Created: 2012-01-06 16:21:32+00:00
State: open

### Description
Using gunicorn with Django as a reverse proxy from Apache and I'm seeing an issue arise periodically whenever I need to restart the gunicorn process. Today it happened on every server in a web farm I was deploying to. Basically whenever a python file changes in the site, I deploy the file and then issue a restart of the gunicorn managed process through supervisor. Here's the relevant config for supervisor. In this log one can see it's trying to shutdown gunicorn and then issue a restart:

```

// supervisor config
[program:gunicorn]
command=gunicorn_django --workers=20 --log-level info --timeout 500 --bind=127.0.0.1:8001
directory=/releases/site
stdout_logfile=/var/log/gunicorn_log
stderr_logfile=/var/log/gunicorn_log
startsecs=10
autostart=true

// gunicorn log
2011-11-22 17:19:26 [3700] [INFO] Worker exiting (pid: 3700)
2011-11-22 17:19:26 [7665] [INFO] Worker exiting (pid: 7665)
2011-11-22 17:19:26 [31401] [INFO] Worker exiting (pid: 31401)
2011-11-22 17:19:26 [31397] [INFO] Worker exiting (pid: 31397)
2011-11-22 17:19:26 [11159] [INFO] Worker exiting (pid: 11159)
INFO:gunicorn.error:Worker exiting (pid: 11159)
2011-11-22 17:19:26 [28158] [INFO] Worker exiting (pid: 28158)
INFO:gunicorn.error:Worker exiting (pid: 28158)
2011-11-22 17:19:26 [28721] [INFO] Worker exiting (pid: 28721)
2011-11-22 17:19:26 [31390] [INFO] Worker exiting (pid: 31390)
Exception SystemExit: 0 in ignored
2011-11-22 17:19:27 [31386] [INFO] Worker exiting (pid: 31386)
2011-11-22 17:19:27 [31385] [INFO] Worker exiting (pid: 31385)
Exception SystemExit: Exception SystemExit: Exception SystemExit: Exception SystemExit: Exception SystemExit: 0 in ignored
0 in ignored
0 in ignored
0 in ignored
0 in ignored
Exception SystemExit: Exception SystemExit: 0 in ignored
Exception SystemExit: 0 in ignored
Exception SystemExit: 0 in ignored
Exception SystemExit: Exception SystemExit: 0 in ignored
Exception SystemExit: 2011-11-22 17:19:27 [31388] [INFO] Worker exiting (pid: 31388)
0 in ignored
0 in ignored
0 in ignored
supervisor: error trying to setuid to 18734 (Can't drop privilege as nonroot user)
2011-11-22 17:19:42 [5929] [INFO] Starting gunicorn 0.13.4
2011-11-22 17:19:42 [5929] [ERROR] Connection in use: ('127.0.0.1', 8001)
2011-11-22 17:19:42 [5929] [ERROR] Retrying in 1 second.
2011-11-22 17:19:43 [5929] [ERROR] Connection in use: ('127.0.0.1', 8001)
2011-11-22 17:19:43 [5929] [ERROR] Retrying in 1 second.
2011-11-22 17:19:44 [5929] [ERROR] Connection in use: ('127.0.0.1', 8001)
2011-11-22 17:19:44 [5929] [ERROR] Retrying in 1 second.
2011-11-22 17:19:45 [5929] [ERROR] Connection in use: ('127.0.0.1', 8001)
2011-11-22 17:19:45 [5929] [ERROR] Retrying in 1 second.
2011-11-22 17:19:46 [5929] [ERROR] Connection in use: ('127.0.0.1', 8001)
2011-11-22 17:19:46 [5929] [ERROR] Retrying in 1 second.
2011-11-22 17:19:47 [5929] [ERROR] Can't connect to ('127.0.0.1', 8001)
```

### Environment
gunicorn 0.13.4
Python 2.7.1
CentOS (Red Hat 4.1.2-50)

Can anyone tell me what is up? I'm having to go and kill hung gunicorn processes manually every time I deploy now and it's making me re-evaluate using gunicorn as the backend.

Thanks