feat: base 提供监测celery的实例
This commit is contained in:
parent
38b7d0c586
commit
a891692b71
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from . import conf
|
from . import conf
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
from celery.app.control import Control, Inspect
|
||||||
|
|
||||||
# set the default Django settings module for the 'celery' program.
|
# set the default Django settings module for the 'celery' program.
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
|
||||||
|
@ -16,6 +17,9 @@ app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||||
# Load task modules from all registered Django app configs.
|
# Load task modules from all registered Django app configs.
|
||||||
app.autodiscover_tasks()
|
app.autodiscover_tasks()
|
||||||
|
|
||||||
|
celery_control: Control = Control(app=app)
|
||||||
|
celery_inspect: Inspect = celery_control.inspect()
|
||||||
|
|
||||||
|
|
||||||
@app.task(bind=True)
|
@app.task(bind=True)
|
||||||
def debug_task(self):
|
def debug_task(self):
|
||||||
|
|
Loading…
Reference in New Issue