2022-04-05 05:22:26 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'application.settings')
|
|
|
|
|
|
|
|
from django.conf import settings
|
|
|
|
from celery import platforms
|
2022-05-18 04:43:11 +00:00
|
|
|
# 租户模式
|
|
|
|
if "django_tenants" in settings.INSTALLED_APPS:
|
2022-04-05 05:22:26 +00:00
|
|
|
from tenant_schemas_celery.app import CeleryApp as TenantAwareCeleryApp
|
2022-05-18 04:43:11 +00:00
|
|
|
|
2022-04-05 05:22:26 +00:00
|
|
|
app = TenantAwareCeleryApp()
|
|
|
|
else:
|
|
|
|
from celery import Celery
|
|
|
|
|
|
|
|
app = Celery(f"application")
|
|
|
|
app.config_from_object('django.conf:settings')
|
|
|
|
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
|
|
|
platforms.C_FORCE_ROOT = True
|