mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -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:
parent
69c994bd16
commit
19c8fe915f
@ -33,6 +33,7 @@ import pexpect
|
||||
|
||||
# Celery
|
||||
from celery import Task, task
|
||||
from celery.signals import celeryd_init, worker_ready
|
||||
|
||||
# Django
|
||||
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')
|
||||
|
||||
@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()
|
||||
def send_notifications(notification_list, job_id=None):
|
||||
if not isinstance(notification_list, list):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user