nginx + uwsgi + django,uwsgi中似乎有一些奇怪的缓存,请帮帮我 [英] nginx+uwsgi+django, there seems to be some strange cache in uwsgi, help me

查看:86
本文介绍了nginx + uwsgi + django,uwsgi中似乎有一些奇怪的缓存,请帮帮我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是uwsgi配置:

[uwsgi]  
uid = 500
listen=200
master = true  
profiler = true 
processes = 8 
logdate = true  
socket = 127.0.0.1:8000  
module = www.wsgi  
pythonpath = /root/www/
pythonpath = /root/www/www 
pidfile = /root/www/www.pid  
daemonize = /root/www/www.log  
enable-threads = true
memory-report = true
limit-as = 6048

这是Nginx配置:

server{  
    listen 80;  
    server_name 119.254.35.221;      
    location / {  
        uwsgi_pass 127.0.0.1:8000;  
        include uwsgi_params;  
    }  
}

django可以正常运行,但是除非我重新启动uwsgi,否则无法看到修改后的页面.(此外,由于我配置了8个工作进程,当我按ctrl + f5一段时间后,可以看到修改后的页面只有某些工作人员可以读取和响应修改后的页面,而其他人仅显示旧页面,谁缓存了旧页面?我没有配置任何有关缓存的内容

The django works ok, but modifed pages can't be seen unless i restart uwsgi.(what's more, as i config 8 worker process, i can see the modified page when i press on ctrl+f5 for a while, seems that only certain worker can read and response the modified page, but others just shows the old one, who caches the old page? i didn't config anything about cache)

我没有配置django,它与"python manager runserver ..."兼容,但是在使用nginx + uwsgi时遇到了这个问题.

I didn't config the django, and it works well with "python manager runserver ...", but havfe this problem when working with nginx+uwsgi.

(nginx和uwsgi都是新安装的,我确定这里没有其他配置.)

(the nginx and uwsgi are both new installation, i'm sure nothing else is configed here..)

推荐答案

  • uwsgi不会自动重新加载代码,只有开发服务器可以自动加载
  • runserver用于调试,uwsgi和nginx用于生产
  • 在生产中,您可以通过service uwsgi restart或通过init.d脚本重新启动uwsgi
  • 使用触摸重新加载

    • uwsgi does not reload your code automatically, only development server does
    • runserver is for debug purposes, uwsgi and nginx for production
    • in production you can restart uwsgi by service uwsgi restart or via init.d script
    • there is even better way to reload uwsg by using touch-reload
    • 通常不需要清理.pyc文件,只有在文件的时间戳错误时才会发生(我在整个carieer上只看到过几次)

      usually there is no need to cleanup .pyc files, it happens only when timestamps on files are wrong (I've seen it only couple times at my entire carieer)

      这篇关于nginx + uwsgi + django,uwsgi中似乎有一些奇怪的缓存,请帮帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆