Reputation: 1776
i was running gunicorn under supervisor with no problems and this weekend it stopped working.
When do application start
inside supervisorctl this is in the application log:
Traceback (most recent call last):
File "/usr/local/bin/gunicorn", line 9, in <module>
load_entry_point('gunicorn==19.0.0', 'console_scripts', 'gunicorn')()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 166, in run
super(Application, self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 71, in run
Arbiter(self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 192, in run
self.halt()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 292, in halt
self.stop()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 343, in stop
time.sleep(0.1)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 209, in handle_chld
self.reap_workers()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 459, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
I'm running application with this configuration:
[program:application]
command=/usr/local/bin/gunicorn application:application -c /home/azureuser/rz-app/gunicorn.conf.py
directory=/home/azureuser/rz-app/
user=root
autostart=true
autorestart=true
redirect_stderr=True
stdout_logfile = /home/azureuser/rz-app/rz-app_log.log
stderr_logfile = /home/azureuser/rz-app/rz-app_errors.log
the contents of the gunicorn.conf.py are the following:
import multiprocessing
bind = "0.0.0.0:5000"
workers = multiprocessing.cpu_count() * 4 + 1
user = 'root'
group = 'root'
max_requests = 200
max_requests_jitter = 20
if i run the command on the terminal outside of supervisor: gunicorn application:application -c gunicorn.conf.py
things work as expected.
This is a flask application and here is the application.py
file:
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import socket
socket.setdefaulttimeout(12)
from werkzeug.contrib.fixers import ProxyFix
from app import application
application.wsgi_app = ProxyFix(application.wsgi_app)
if __name__ == '__main__':
application.run(host='0.0.0.0', port=5000, debug=False)
How can i fix this?
EDIT: I have noticed that it seems to be a problem with the root user, when outside supervisor, i ran:
sudo /usr/local/bin/gunicorn application:application -c /home/azureuser/rz-app/gunicorn.conf.py
, everything works, but when i do:
sudo su
followed by /usr/local/bin/gunicorn application:application -c /home/azureuser/rz-app/gunicorn.conf.py
it doesn't work
Upvotes: 2
Views: 1386
Reputation: 1776
Found the problem, it had nothing to do with gunicorn or supervisor, my application had a dependency that was downloaded only in the user, and i noticed when i did sudo su
before the command, the same problem appeared, so i logged what was happening while being root /usr/local/bin/gunicorn --log-file=- application:application -c /home/azureuser/rz-app/gunicorn.conf.py
, added --log-file=-
and found out the error that was plaguing me.
Upvotes: 1