mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 21:21:21 -03:30
Beat and celery clustering fixes
* use embedded beat rather than standalone * dynamically set celeryd hostname at runtime * add embeded beat flag to celery startup * Embedded beat mode routes will piggyback off of celery worker setup signal
This commit is contained in:
parent
624289bed7
commit
0e97dc4b84
2
Makefile
2
Makefile
@ -23,7 +23,7 @@ COMPOSE_HOST ?= $(shell hostname)
|
||||
|
||||
VENV_BASE ?= /venv
|
||||
SCL_PREFIX ?=
|
||||
CELERY_SCHEDULE_FILE ?= /celerybeat-schedule
|
||||
CELERY_SCHEDULE_FILE ?= /var/lib/awx/beat.db
|
||||
|
||||
DEV_DOCKER_TAG_BASE ?= gcr.io/ansible-tower-engineering
|
||||
# Python packages to install only from source (not from binary wheels)
|
||||
|
||||
@ -26,7 +26,7 @@ except Exception:
|
||||
|
||||
# Celery
|
||||
from celery import Task, shared_task
|
||||
from celery.signals import celeryd_init, worker_process_init, worker_shutdown, worker_ready, beat_init
|
||||
from celery.signals import celeryd_init, worker_process_init, worker_shutdown, worker_ready, celeryd_after_setup
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
@ -168,7 +168,6 @@ def handle_ha_toplogy_worker_ready(sender, **kwargs):
|
||||
.format(instance.hostname, removed_queues, added_queues))
|
||||
|
||||
|
||||
@beat_init.connect
|
||||
@celeryd_init.connect
|
||||
def handle_update_celery_routes(sender=None, conf=None, **kwargs):
|
||||
conf = conf if conf else sender.app.conf
|
||||
@ -179,6 +178,13 @@ def handle_update_celery_routes(sender=None, conf=None, **kwargs):
|
||||
.format(instance.hostname, added_routes, conf.CELERY_ROUTES))
|
||||
|
||||
|
||||
@celeryd_after_setup.connect
|
||||
def handle_update_celery_hostname(sender, instance, **kwargs):
|
||||
tower_instance = Instance.objects.me()
|
||||
instance.hostname = 'celery@{}'.format(tower_instance.hostname)
|
||||
logger.warn("Set hostname to {}".format(instance.hostname))
|
||||
|
||||
|
||||
@shared_task(queue='tower', base=LogErrorsTask)
|
||||
def send_notifications(notification_list, job_id=None):
|
||||
if not isinstance(notification_list, list):
|
||||
|
||||
@ -3,7 +3,7 @@ nodaemon = True
|
||||
umask = 022
|
||||
|
||||
[program:celery]
|
||||
command = /var/lib/awx/venv/awx/bin/celery worker -A awx -l debug --autoscale=4 -Ofair -Q tower_broadcast_all -n celery@%(ENV_HOSTNAME)s
|
||||
command = /var/lib/awx/venv/awx/bin/celery worker -A awx -B -l debug --autoscale=4 -Ofair -s /var/lib/awx/beat.db -Q tower_broadcast_all -n celery@$(ENV_HOSTNAME)s
|
||||
directory = /var/lib/awx
|
||||
environment = LANGUAGE="en_US.UTF-8",LANG="en_US.UTF-8",LC_ALL="en_US.UTF-8",LC_CTYPE="en_US.UTF-8"
|
||||
#user = {{ aw_user }}
|
||||
@ -15,18 +15,6 @@ stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
|
||||
[program:awx-celeryd-beat]
|
||||
command = /var/lib/awx/venv/awx/bin/celery beat -A awx -l debug --pidfile= -s /var/lib/awx/beat.db
|
||||
directory = /var/lib/awx
|
||||
autostart = true
|
||||
autorestart = true
|
||||
stopwaitsecs = 5
|
||||
redirect_stderr=true
|
||||
stdout_logfile = /dev/stdout
|
||||
stdout_logfile_maxbytes = 0
|
||||
stderr_logfile = /dev/stderr
|
||||
stderr_logfile_maxbytes = 0
|
||||
|
||||
[program:callback-receiver]
|
||||
command = awx-manage run_callback_receiver
|
||||
directory = /var/lib/awx
|
||||
|
||||
@ -4,7 +4,7 @@ minfds = 4096
|
||||
nodaemon=true
|
||||
|
||||
[program:celeryd]
|
||||
command = celery worker -A awx -l DEBUG -B -Ofair --autoscale=100,4 --schedule=/celerybeat-schedule -Q tower_broadcast_all -n celery@%(ENV_HOSTNAME)s
|
||||
command = celery worker -A awx -l DEBUG -B --autoscale=20,3 -Ofair -s /var/lib/awx/beat.db -Q tower_broadcast_all -n celery@%(ENV_HOSTNAME)s
|
||||
autostart = true
|
||||
autorestart = true
|
||||
redirect_stderr=true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user