How can I exit uWsgi worker (python werkzeug) from internal error?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 03:23:54

问题


I have a RESTful API written in python using werkzeug. It runs with nginx/uWsgi. I would like to kill worker process when an internal error (LOST zookeeper session) occurs and let uWsgi will spawn a new worker.

If I call sys.exit(0), worker does not exit. Perhaps SystemExit or Exception is being caught somewhere. I am running as a service using init script with,

exec $root/run uwsgi --socket 127.0.0.1:3037 --master --workers 4 --threads 10 --harakiri 60 --die-on-term --thunder-lock --lazy-apps --py-tracebacker /tmp/ledgerwebtbsock --wsgi-file my_server.py --logto /my_server.py


回答1:


uwsgi --help | grep on-exception

Returns a bunch of options to control automatically restarting workers when a specific exception is raised:

--reload-on-exception                   reload a worker when an exception is raised
--reload-on-exception-type              reload a worker when a specific exception type is raised
--reload-on-exception-value             reload a worker when a specific exception value is raised
--reload-on-exception-repr              reload a worker when a specific exception type+value (language-specific) is raised

Check out slide 9 from Roberto de Ioris's 10 uWSGI tricks - DjangoDay 2012 presentation for more.



来源:https://stackoverflow.com/questions/28235725/how-can-i-exit-uwsgi-worker-python-werkzeug-from-internal-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!