feat: base 做到celery在项目间完全隔离

This commit is contained in:
caoqianming 2023-12-05 08:51:07 +08:00
parent 1a09787853
commit b744ac4591
2 changed files with 4 additions and 3 deletions

View File

@ -1,11 +1,11 @@
import os
from . import conf
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
app = Celery('ehs')
app = Celery(conf.BASE_PROJECT_CODE)
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.

View File

@ -282,7 +282,7 @@ AUTHENTICATION_BACKENDS = (
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": conf.REDIS_LOCATION,
"LOCATION": conf.CACHE_LOCATION,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
@ -291,6 +291,7 @@ CACHES = {
# celery配置,celery正常运行必须安装redis
CELERY_BROKER_URL = conf.CELERY_BROKER_URL # 任务存储
CELERY_TASK_DEFAULT_QUEUE = conf.CELERY_TASK_DEFAULT_QUEUE # 任务队列
CELERYD_MAX_TASKS_PER_CHILD = 100 # 每个worker最多执行100个任务就会被销毁可防止内存泄露
CELERY_TIMEZONE = 'Asia/Shanghai' # 设置时区
CELERY_ENABLE_UTC = True # 启动时区设置