单个服务器中具有多个虚拟环境项目的Django uwsgi celery守护进程

时间:2019-05-04 12:11:18

标签: nginx redis uwsgi django-celery celerybeat

有可能使用uwsgi的attach-daemon2在不同的虚拟环境项目中运行多个celery worker吗?在每个项目的.ini uwsgi配置文件中,我添加了相同的守护程序。只是一件作品。

/etc/uwsgi/app-available/proj1.ini

[uwsgi]
virtualenv=/var/apps/proj1.com
processes=4
chdir=/var/apps/proj1.com
socket=/tmp/proj1.ini.socket
workers=32
chmod-socket=666
touch-reload=./uwsgi_reload
module=theapp.wsgi:application
cheaper=2
cheaper-initial=2
idle=300
cheaper-step=1
env=LC_ALL=es_ES.UTF-8
plugins=python35
threads=2
attach-daemon2 = stopsignal=13,reloadsignal=13,cmd=bin/celery multi start w_%n --app=theapp --concurrency=1 --schedule=/var/run/celery/%n_celerybeat-schedule --pidfile=/var/run/celery/%n_celery.pid --loglevel=ERROR --logfile=/var/log/celery/%n.log --beat

/etc/uwsgi/app-available/proj2.ini

[uwsgi]
virtualenv=/var/apps/proj2.com
processes=4
chdir=/var/apps/proj2.com
socket=/tmp/proj2.ini.socket
workers=32
chmod-socket=666
touch-reload=./uwsgi_reload
module=theapp.wsgi:application
cheaper=2
cheaper-initial=2
idle=300
cheaper-step=1
env=LC_ALL=es_ES.UTF-8
plugins=python35
threads=2
attach-daemon2 = stopsignal=13,reloadsignal=13,cmd=bin/celery multi start w_%n --app=theapp --concurrency=1 --schedule=/var/run/celery/%n_celerybeat-schedule --pidfile=/var/run/celery/%n_celery.pid --loglevel=ERROR --logfile=/var/log/celery/%n.log --beat

/var/apps/proj1.com/theapp/settings.py

WSGI_APPLICATION = 'theapp.wsgi.application'

# CELERY
BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CACHES = {
    'default': {
        "BACKEND": "redis_cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379/0",
    }
}

/var/apps/proj2.com/theapp/settings.py

WSGI_APPLICATION = 'theapp.wsgi.application'

# CELERY
BROKER_URL = 'redis://localhost:6379/1'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/1'
CACHES = {
    'default': {
        "BACKEND": "redis_cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379/1",
    }
}

0 个答案:

没有答案