日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

python之uwsgi配置

系統 1980 0

uwsg基礎配置

            
              [uwsgi]
# 當前文件所處的文件夾
chdir=%d
project_name=%c
user=@(exec://whoami)
virtualenv=/home/keithl/workdir/python/pyenv/%(project_name)
# load a WSGI module
wsgi-file=wsgi_admin_handler.py
master=true

# set the socket listen queue size
listen=100
# 本機內網ip
lanip=@(exec://hostname -I|awk '{print $NF}')
# 本機外網ip
comboip=@(exec://hostname -I|awk '{print $1}')

# 設置端口
http=%(lanip):9000

# 設置進程數
processes=4

print=%(http)
pidfile=%(chdir)logs/uwsgi.pid
# supervisor transfrom process into daemon
vacuum=true
auto-procname=true
procname-prefix-spaced=%(user)_%(project_name)
# supervisorctl restart
touch-reload=/home/keithl/workdir/python/pyenv/cgi_reload_file/%(project_name)
#touch-reload=wsgi_handler.py
enable-threads=true
lazy-apps=true


# 日志
show-config=true
log-maxsize=0
logfile-chmod=644
logfile-chown=true


# daemonize=%(chdir)logs/uwsgi_default.log
logto=%(chdir)logs/uwsgi_default.log
req-logger=file:%(chdir)logs/uwsgi_req.log

exec-asap=mkdir -p %(chdir)logs
exec-asap=touch %(chdir)logs/uwsgi_default.log
exec-asap=chmod 644 %(chdir)logs/uwsgi_default.log
exec-asap=touch %(chdir)logs/uwsgi_req.log
exec-asap=chmod 644 %(chdir)logs/uwsgi_req.log

# 日志切割
cron = -30 -1 -1 -1 -1 find %(chdir)logs \( -name "uwsgi_req.log" -o -name "uwsgi_default.log" -o -name "default.log" -o -name "epay.log" -o -name "leazy-error-log" -o -name "leazy-info-log" -o -name "leazy-debug-log" -o -name "error.log" \) -size +100M -exec cp {} {}.`date +"%%Y-%%m-%%d_%%H:%%M:%%S"`.rotate.log \; -exec truncate {} --size 0 \;

# 壓縮 每天凌晨2:56將logs目錄下后綴是rotate.log的,且最后修改時間在1天以上的日志,用gzip壓縮
cron = 56 2 -1 -1 -1 find %(chdir)logs -mtime +1 -name "*.rotate.log" -exec gzip {} \;

# 刪除舊的日志 每天凌晨 3:56將太舊的備份文件刪除,保留一個月吧,后綴是rotate.log.gz
cron = 56 3 -1 -1 -1 find %(chdir)logs -mtime +31 -name "*.rotate.log.gz" -exec rm {} \;

            
          

使用supervisord配置啟動

            
              
                [
              
              program:cclive
              
                ]
              
              
directory
              
                =
              
              /home/cc/webcc/cclive
command
              
                =
              
              /home/cc/.virtualenvs/webdd/bin/uwsgi webdd_uwsgi.ini
user
              
                =
              
              cc
numprocs
              
                =
              
              1
stdout_logfile
              
                =
              
              /home/cc/webcc/cclive/logs/uwsgi_console.log
redirect_stderr
              
                =
              
              true
autostart
              
                =
              
              true
autorestart
              
                =
              
              true
startsecs
              
                =
              
              10
stopwaitsecs
              
                =
              
              600
killasgroup
              
                =
              
              true
priority
              
                =
              
              998
stopsignal
              
                =
              
              QUIT


              
                [
              
              program:cclive_celery
              
                ]
              
              
directory
              
                =
              
              /home/cc/webcc/cclive
command
              
                =
              
              /home/cc/.virtualenvs/webdd/bin/celery --app
              
                =
              
              webdd.celery:app worker --loglevel
              
                =
              
              INFO -Ofair --time-limit
              
                =
              
              120
user
              
                =
              
              cc
numprocs
              
                =
              
              1
stdout_logfile
              
                =
              
              /home/cc/webcc/cclive/logs/celery_console.log
redirect_stderr
              
                =
              
              true
autostart
              
                =
              
              true
autorestart
              
                =
              
              true
startsecs
              
                =
              
              10
stopwaitsecs
              
                =
              
              600
killasgroup
              
                =
              
              true
priority
              
                =
              
              998

            
          

使用celery配置django

            
              
                # celery.py
              
              
                from
              
               __future__ 
              
                import
              
               absolute_import


              
                import
              
               os


              
                from
              
               celery 
              
                import
              
               Celery


              
                from
              
               django
              
                .
              
              conf 
              
                import
              
               settings


              
                # set the default Django settings module for the 'celery' program.
              
              
os
              
                .
              
              environ
              
                .
              
              setdefault
              
                (
              
              
                'DJANGO_SETTINGS_MODULE'
              
              
                ,
              
              
                'webdd.settings'
              
              
                )
              
              

app 
              
                =
              
               Celery
              
                (
              
              
                'webdd'
              
              
                )
              
              
                # Using a string here means the worker will not have to
              
              
                # pickle the object when using Windows.
              
              
app
              
                .
              
              config_from_object
              
                (
              
              
                'django.conf:settings'
              
              
                )
              
              
app
              
                .
              
              autodiscover_tasks
              
                (
              
              
                lambda
              
              
                :
              
               settings
              
                .
              
              INSTALLED_APPS
              
                )
              
            
          

更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。?!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 天峻县| 上杭县| 盐亭县| 洞口县| 手机| 辛集市| 曲松县| 图片| 永州市| 新兴县| 锡林浩特市| 云林县| 钟山县| 清水河县| 琼结县| 中西区| 剑阁县| 亚东县| 阿城市| 海南省| 承德市| 彰武县| 慈利县| 边坝县| 西宁市| 武清区| 阿合奇县| 夏河县| 融水| 开江县| 上饶县| 鱼台县| 光山县| 舟山市| 许昌市| 普陀区| 裕民县| SHOW| 宁阳县| 阿荣旗| 仲巴县|