uWSGI + Django 配置

基本配置:

# mysite_uwsgi.ini file
[uwsgi]

# Django-related settings
# the base directory (full path)
chdir           = /path/to/your/project
# Django's wsgi file
module          = project.wsgi
# the virtualenv (full path)
home            = /path/to/virtualenv

# process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 10
# the socket (use the full path to be safe
socket          = /path/to/your/project/mysite.sock
# ... with appropriate permissions - may be needed
# chmod-socket    = 664
# clear environment on exit
vacuum          = true

扩展配置:

# set an environment variable
env = DJANGO_SETTINGS_MODULE=mysite.settings

# create a pidfile
safe-pidfile = /tmp/project-master.pid

# respawn processes taking more than 20 seconds
harakiri = 20

# limit the project to 128 MB
limit-as = 128

# respawn processes after serving 5000 requests
max-requests = 5000

# background the process & log
daemonize = /var/log/uwsgi/yourproject.log
[uwsgi]

chdir = /path/to/your/project
module = project.wsgi
http-socket = :5000
master = true
harakiri = 20  # respawn processes taking more than 20 seconds
max-requests = 5000  # respawn processes after serving 5000 requests
chmod-socket=664  # django 配置
vacuum = true

# uwsgi默认的顶戴队列, linux的默认限制是128, 查看 cat /proc/sys/net/core/somaxconn
# listen = 100

# 弹性调整打开的 worker 数目
cheaper-algo = spare2
cheaper = 2           # tries to keep 8 idle workers
cheaper-initial = 4   # starts with minimal workers
cheaper-step = 1      # spawn at most 4 workers at once
cheaper-idle = 60     # cheap one worker per minute while idle
workers = 8           # maximum number of workers
# processes = 4
# threads = 2

stats = :6000
stats-http = true
# log-maxsize = 10000000
logto = http_uwsgi.log
log-slow = 3000  # 记录满于 3000 毫秒的请求
log-format = %(addr) - %(user) [%(ltime)] "%(method) %(uri) %(proto)" %(status) %(size) "%(referer)" "%(uagent)"
# disable-logging = true

# https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/articles/TheArtOfGracefulReloading.html
# reload uWSGI if the specified file is modified/touched
# touch-reload 和 preforking组合,uwsgi 默认的优雅重载(热启动)
touch-reload = uwsgi.ini

# lazy-apps and touch-workers-reload,优雅重载的另一个模式
# lazy-apps = true
# 重载 workder
# touch-workers-reload = uwsgi.ini
# 链式重载
# touch-chain-reload = uwsgi.ini

py-autoreload = 1  # 自动重载,开发时非常方便

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值