How to create one uwsgi log file per day?

前端 未结 4 740
小鲜肉
小鲜肉 2021-02-14 13:11

I use uwsgi with the parameter --daemonize /logs/uwsgi.log

This file is however becoming large and I would like to split it into smaller pieces. One per day would be pre

4条回答
  •  悲哀的现实
    2021-02-14 13:39

    [uwsgi]
    
    wsgi-file = bean/wsgi.py
    
    # 重启时间
    # harakiri = 10
    
    # 主进程
    master = true
    
    # 4个进程/workers
    processes = 4
    
    # 两个核心
    threads = 2
    
    # 开启线程
    enable-threads = true
    
    # 单个进程最大请求数
    max-requests = 5000
    
    # 解包缓冲区大小
    buffer-size = 65536
    
    reload-mercy = 8
    
    stats = 127.0.0.1:5000
    
    pidfile = /var/run/itpserver.pid
    
    vacuum = true
    
    disable-logging = true
    
    logto = /opt/logs/uwsgi.log
    
    touch-logreopen = /opt/logs/.touchforlogrotat
    
    

    And

    #!/bin/bash
    
    if [ ${ITM_CONFIG}=="test" ]
    then
    LOGDIR="/home/logs"
    else
    LOGDIR="/opt/logs"
    fi
    
    DATE=`date -d "yesterday" +"%Y-%m-%d"`
    
    BACKUPCOUNT="7"
    
    DELDATE=`date -d "${BACKUPCOUNT} day ago" +"%Y-%m-%d"`
    
    mv ${LOGDIR}/uwsgi.log   ${LOGDIR}/uwsgi.${DATE}.log
    
    rm -f ${LOGDIR}/uwsgi.${DELDATE}.log
    
    touch ${LOGDIR}/.touchforlogrotat
    

    And add crontab with this sh:

    @daily sh /home/share/logbackups.sh # uwsgilogrotat
    

    A friendlier way

提交回复
热议问题