[uwsgi]
socket = 0.0.0.0:9101
module = wsgi
master = 1
#设置socket监听队列大小
listen = 128
#魔术变量 https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/Configuration.html
cpu_num = %k
processes = %(cpu_num + 1)
threads = 10
pythonpath = %d
pidfile2 = %dtmp/uwsgi.pid
profiler = true
memory-report = true
vacuum = true
enable-threads = true
#https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/AttachingDaemons.html
#smart-attach-daemon = %dtmp/memcached.pid memcached  -d -P %dtmp/memcached.pid -u memcached -m 1024 -d
#smart-attach-daemon = %dtmp/celery.pid celery -A celery_app worker -l info -P gevent -c 1000 -E -n 2 --pidfile=%dtmp/celery.pid
#smart-attach-daemon = %dtmp/celery_flower.pid celery -A celery_app flower  --address=0.0.0.0 --port=5555 --pidfile=%dtmp/celery_flower.pid

#限制进程地址空间/vsz
limit-as = 6048
#如果worker的rss内存比指定百万字节高，那么强制master重载这个worker
#evil-reload-on-rss = 500

#日志切割------------------
#修改指定文件重新打开日志,不使用touch-logrotate和log-backupname 是因为会造成 uwsgi.log.rotated ????????? 消失
set-ph = touch_file=%dtmp/.uwsgi.touch
touch-logreopen = %(touch_file)
#修改指定文件reload worker 并重新打开日志文件,不能使用touch-reload,master还在执行cron不能重启
touch-workers-reload = %(touch-logreopen)
#touch-logreopen worker并不会重新打开打开日志文件,需要reload workers 并 设置 log-reopen
log-reopen = true
logdate = true
logto = %dlogs/uwsgi.log
#默认不打开daemon模式,配合在supervisord监控,可以通过启动脚本增加-d参数
#daemonize = $(logto)
threaded-logger = true

#保留日志数量
set-ph = log_num=10
#每天0点1分分割日志,定时重命名日志,并重新加载新日志文件名
unique-cron = 1 0 -1 -1 -1 LOGFILE="%(logto).$(date -d '-1 hour' +%%Y-%%m-%%d)" && CMD="rm -rf $LOGFILE ;mv %(logto) $LOGFILE ; rm -rf %(logto).$(date -d '-%(log_num) day' +%%Y-%%m-%%d)" && /bin/sh -c "$CMD" &&  echo "[`date`] $CMD" > %(touch_file)
#--------------------------

#gevent设置----
#gevent=100
#gevent-monkey-patch=true
#-------------
#代码更新,自动重启
#py-autoreload=1