|
|
|
@ -15,7 +15,10 @@ from .celery.decorator import (
|
|
|
|
|
register_as_period_task, after_app_shutdown_clean_periodic,
|
|
|
|
|
after_app_ready_start
|
|
|
|
|
)
|
|
|
|
|
from .celery.utils import create_or_update_celery_periodic_tasks
|
|
|
|
|
from .celery.utils import (
|
|
|
|
|
create_or_update_celery_periodic_tasks, get_celery_periodic_task,
|
|
|
|
|
disable_celery_periodic_task, delete_celery_periodic_task
|
|
|
|
|
)
|
|
|
|
|
from .models import Task, CommandExecution, CeleryTask
|
|
|
|
|
from .utils import send_server_performance_mail
|
|
|
|
|
|
|
|
|
@ -95,6 +98,29 @@ def clean_celery_tasks_period():
|
|
|
|
|
subprocess.call(command, shell=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@shared_task
|
|
|
|
|
@after_app_ready_start
|
|
|
|
|
def clean_celery_periodic_tasks():
|
|
|
|
|
"""清除celery定时任务"""
|
|
|
|
|
need_cleaned_tasks = [
|
|
|
|
|
'handle_be_interrupted_change_auth_task_periodic',
|
|
|
|
|
]
|
|
|
|
|
logger.info('Start clean celery periodic tasks: {}'.format(need_cleaned_tasks))
|
|
|
|
|
for task_name in need_cleaned_tasks:
|
|
|
|
|
logger.info('Start clean task: {}'.format(task_name))
|
|
|
|
|
task = get_celery_periodic_task(task_name)
|
|
|
|
|
if task is None:
|
|
|
|
|
logger.info('Task does not exist: {}'.format(task_name))
|
|
|
|
|
continue
|
|
|
|
|
disable_celery_periodic_task(task_name)
|
|
|
|
|
delete_celery_periodic_task(task_name)
|
|
|
|
|
task = get_celery_periodic_task(task_name)
|
|
|
|
|
if task is None:
|
|
|
|
|
logger.info('Clean task success: {}'.format(task_name))
|
|
|
|
|
else:
|
|
|
|
|
logger.info('Clean task failure: {}'.format(task))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@shared_task
|
|
|
|
|
@after_app_ready_start
|
|
|
|
|
def create_or_update_registered_periodic_tasks():
|
|
|
|
|