uwsgi如何安全停止?

1.看官网文档,使用-HUP可以优雅重启,不过我在测试的时候,却是直接杀死了,并没有等待请求处理结束(难道是因为我使用time.sleep(10)来模拟长作业的缘故?),日志如下,虽然显示200,不过浏览器那边却“连接已中断”

...gracefully killing workers...
Gracefully killing worker 2 (pid: 9610)...
Gracefully killing worker 1 (pid: 9609)...
Gracefully killing worker 3 (pid: 9611)...
Gracefully killing worker 4 (pid: 9639)...
worker 1 buried after 1 seconds
worker 2 buried after 1 seconds
worker 3 buried after 1 seconds
[pid: 9639|app: 0|req: 11/14] 111.206.83.99 () {42 vars in 1782 bytes} [Tue Jul  8 17:59:16 2014] GET /config/long => generated 2 bytes in 5005 msecs (HTTP/1.1 200) 1 headers in 51 bytes (1 switches on core 14)
worker 4 buried after 4 seconds

2.如何安全停止服务器?文档中似乎只有-INT是停止,不过似乎是直接干掉了uwsgi,并不等所有请求处理完成

3.Python Webservice在数据一致性,服务可靠性要求高的情况下,如何选择服务器?要求可以优雅停止、重启。

阅读 13.8k
3 个回答

前端添加上nginx就可以满足你的需求了

我喜欢用gunicorn,uwsgi太麻烦。
gunicorn+flask/django+nginx+mysql/mongodb

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
1 篇内容引用
推荐问题