mirror of
https://github.com/ansible/awx.git
synced 2026-02-22 13:36:02 -03:30
Add a celery worker init task
We'll use this task to perform any worker specific startup actions. Initially this is used to re-sync any Tower schedules on startup.
This commit is contained in:
@@ -33,6 +33,7 @@ import pexpect
|
|||||||
|
|
||||||
# Celery
|
# Celery
|
||||||
from celery import Task, task
|
from celery import Task, task
|
||||||
|
from celery.signals import celeryd_init, worker_ready
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -67,6 +68,17 @@ Try upgrading OpenSSH or providing your private key in an different format. \
|
|||||||
|
|
||||||
logger = logging.getLogger('awx.main.tasks')
|
logger = logging.getLogger('awx.main.tasks')
|
||||||
|
|
||||||
|
@celeryd_init.connect
|
||||||
|
def celery_startup(conf=None, **kwargs):
|
||||||
|
# Re-init all schedules
|
||||||
|
# NOTE: Rework this during the Rampart work
|
||||||
|
logger.info("Syncing Tower Schedules")
|
||||||
|
for sch in Schedule.objects.all():
|
||||||
|
try:
|
||||||
|
sch.update_computed_fields()
|
||||||
|
except Exception, e:
|
||||||
|
logger.error("Failed to rebuild schedule {}: {}".format(sch, e))
|
||||||
|
|
||||||
@task()
|
@task()
|
||||||
def send_notifications(notification_list, job_id=None):
|
def send_notifications(notification_list, job_id=None):
|
||||||
if not isinstance(notification_list, list):
|
if not isinstance(notification_list, list):
|
||||||
|
|||||||
Reference in New Issue
Block a user