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

python之uwsgi配置

系統(tǒng) 1907 0

uwsg基礎(chǔ)配置

            
              [uwsgi]
# 當(dāng)前文件所處的文件夾
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
# 本機(jī)內(nèi)網(wǎng)ip
lanip=@(exec://hostname -I|awk '{print $NF}')
# 本機(jī)外網(wǎng)ip
comboip=@(exec://hostname -I|awk '{print $1}')

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

# 設(shè)置進(jìn)程數(shù)
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的,且最后修改時(shí)間在1天以上的日志,用gzip壓縮
cron = 56 2 -1 -1 -1 find %(chdir)logs -mtime +1 -name "*.rotate.log" -exec gzip {} \;

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

            
          

使用supervisord配置啟動(dòng)

            
              
                [
              
              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
              
                )
              
            
          

更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

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

【本文對您有幫助就好】

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

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 仁怀市| 舒兰市| 甘南县| 固镇县| 天长市| 蛟河市| 恭城| 吴堡县| 湟中县| 宝丰县| 北票市| 乐至县| 德保县| 鸡泽县| 株洲县| 通渭县| 宁波市| 桓仁| 临安市| 定南县| 左贡县| 汽车| 张家口市| 疏勒县| 苗栗市| 巴楚县| 南部县| 镇巴县| 饶平县| 临桂县| 南昌县| 旺苍县| 乐昌市| 漠河县| 宁化县| 西藏| 桦甸市| 壤塘县| 济南市| 南投市| 襄汾县|