mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-04 17:01:09 +00:00
fix: ldap定时任务未执行
This commit is contained in:
@@ -144,10 +144,10 @@ def clean_job_execution_period():
|
|||||||
del_res = JobExecution.objects.filter(date_created__lt=expired_day).delete()
|
del_res = JobExecution.objects.filter(date_created__lt=expired_day).delete()
|
||||||
logger.info(f"clean job_execution db record success! delete {days} days {del_res[0]} records")
|
logger.info(f"clean job_execution db record success! delete {days} days {del_res[0]} records")
|
||||||
|
|
||||||
|
# 测试使用,注释隐藏
|
||||||
@shared_task
|
# @shared_task
|
||||||
def longtime_add(x, y):
|
# def longtime_add(x, y):
|
||||||
print('long time task begins')
|
# print('long time task begins')
|
||||||
time.sleep(50)
|
# time.sleep(50)
|
||||||
print('long time task finished')
|
# print('long time task finished')
|
||||||
return x + y
|
# return x + y
|
||||||
|
@@ -9,7 +9,7 @@ from common.utils import get_logger
|
|||||||
from common.utils.timezone import local_now_display
|
from common.utils.timezone import local_now_display
|
||||||
from ops.celery.decorator import after_app_ready_start
|
from ops.celery.decorator import after_app_ready_start
|
||||||
from ops.celery.utils import (
|
from ops.celery.utils import (
|
||||||
create_or_update_celery_periodic_tasks, disable_celery_periodic_task
|
create_or_update_celery_periodic_tasks, delete_celery_periodic_task
|
||||||
)
|
)
|
||||||
from orgs.models import Organization
|
from orgs.models import Organization
|
||||||
from settings.notifications import LDAPImportMessage
|
from settings.notifications import LDAPImportMessage
|
||||||
@@ -69,6 +69,7 @@ def import_ldap_user_periodic():
|
|||||||
if not settings.AUTH_LDAP:
|
if not settings.AUTH_LDAP:
|
||||||
return
|
return
|
||||||
task_name = 'import_ldap_user_periodic'
|
task_name = 'import_ldap_user_periodic'
|
||||||
|
delete_celery_periodic_task(task_name)
|
||||||
if not settings.AUTH_LDAP_SYNC_IS_PERIODIC:
|
if not settings.AUTH_LDAP_SYNC_IS_PERIODIC:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -85,8 +86,7 @@ def import_ldap_user_periodic():
|
|||||||
task_name: {
|
task_name: {
|
||||||
'task': import_ldap_user.name,
|
'task': import_ldap_user.name,
|
||||||
'interval': interval,
|
'interval': interval,
|
||||||
'crontab': crontab,
|
'crontab': crontab
|
||||||
'enabled': True,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
create_or_update_celery_periodic_tasks(tasks)
|
create_or_update_celery_periodic_tasks(tasks)
|
||||||
|
Reference in New Issue
Block a user