Create singlethreaded services worker

This commit is contained in:
Joel Falknau 2025-03-06 10:19:51 +10:00
parent c7db4f0bd3
commit f1145c09c0
No known key found for this signature in database
4 changed files with 33 additions and 0 deletions

View File

@ -31,6 +31,13 @@ app.conf.ONCE = {
'settings': {} 'settings': {}
} }
app.conf.task_routes = {
# Some AA Services are sensitive to threaded tasks
# Utilize a single threaded worker to process these tasks
# Discord: Multithreads can cause duplicate role creation.
"discord.*": {"queue": "services"},
}
# Load task modules from all registered Django app configs. # Load task modules from all registered Django app configs.
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

View File

@ -24,6 +24,21 @@ stopwaitsecs = 600
killasgroup=true killasgroup=true
priority=998 priority=998
[program:worker_services]
command={{ celery }} -A {{ project_name }} worker --pool=threads --concurrency=1 -Q services -n %(program_name)s_%(process_num)02d
directory={{ project_directory }}
user=allianceserver
numprocs=1
process_name=%(program_name)s_%(process_num)02d
stdout_logfile={{ project_directory }}/log/worker_services.log
stderr_logfile={{ project_directory }}/log/worker_services.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=998
{% if gunicorn %} {% if gunicorn %}
[program:gunicorn] [program:gunicorn]
user = allianceserver user = allianceserver

View File

@ -31,6 +31,13 @@ app.conf.ONCE = {
'settings': {} 'settings': {}
} }
app.conf.task_routes = {
# Some AA Services are sensitive to threaded tasks
# Utilize a single threaded worker to process these tasks
# Discord: Multithreads can cause duplicate role creation.
"discord.*": {"queue": "services"},
}
# Load task modules from all registered Django app configs. # Load task modules from all registered Django app configs.
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

View File

@ -103,6 +103,10 @@ services:
deploy: deploy:
replicas: 2 replicas: 2
allianceauth_worker_services:
<<: [*allianceauth-base, *allianceauth-health-checks]
entrypoint: ["celery", "-A", "myauth", "worker", "--pool=threads", "--concurrency=1", "-Q" , "services" , "-n", "worker_services_%n"]
grafana: grafana:
image: grafana/grafana-oss:latest image: grafana/grafana-oss:latest
restart: always restart: always