wsgi服务的页面无法刷新
我最近成功让我的第一个应用在uWSGI和Cherokee上运行。为了实现这一点,我使用了从uWSGI文档上找到的以下代码:
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
yield 'Hello World\n'
页面正确显示了Hello World
。但是当我把这个文本改成New Thing
并刷新页面时,什么也没有变化。我忘记了什么呢?
我尝试过的办法:
- 清除浏览器历史记录和缓存
- 停止并重新启动Cherokee
补充说明:我在Python代码中把
Hello World
改成了New Thing
。然后我停止Cherokee,刷新页面,结果明显看到一个错误信息。接着我重新启动Cherokee,再刷新页面,结果又看到Hello World
。
1 个回答
2
这个过程的工作原理是,Cherokee 在后台为你管理一个正在运行的 uwsgi 实例。我注意到的一点是,如果你关闭 Cherokee,它似乎并不会同时关闭正在运行的 uwsgi 实例。
你可以试试这个:
sudo service cherokee start
ps aux | grep uwsgi
# you should see nothing from this ps command
# now hit your web app
sudo service cherokee stop
ps aux | grep uwsgi
# you should see the instance of uwsgi that cherokee started
你的应用代码实际上是通过 uwsgi 来运行的,而 Cherokee 更像是一个代理服务器。要更新应用代码,你需要向 uwsgi 发送 HUP 信号,而不是给 Cherokee。
sudo killall -HUP uwsgi
这样做应该能让 uwsgi 更新你的应用更改,而不管 Cherokee 的状态。