Skip to content

Commit 5cc2bdd

Browse files
Generate unique Celery worker name (#7827)
1 parent 7cbacf2 commit 5cc2bdd

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

services/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,7 @@ services:
12491249
hostname: "sto-worker-{{.Node.Hostname}}-{{.Task.Slot}}"
12501250
environment:
12511251
<<: *storage_environment
1252+
STORAGE_WORKER_NAME: "sto-worker-{{.Node.Hostname}}-{{.Task.Slot}}-{{.Task.ID}}"
12521253
STORAGE_WORKER_MODE: "true"
12531254
CELERY_CONCURRENCY: 100
12541255
networks: *storage_networks
@@ -1259,6 +1260,7 @@ services:
12591260
hostname: "sto-worker-cpu-bound-{{.Node.Hostname}}-{{.Task.Slot}}"
12601261
environment:
12611262
<<: *storage_environment
1263+
STORAGE_WORKER_NAME: "sto-worker-cpu-bound-{{.Node.Hostname}}-{{.Task.Slot}}-{{.Task.ID}}"
12621264
STORAGE_WORKER_MODE: "true"
12631265
CELERY_CONCURRENCY: 1
12641266
CELERY_QUEUES: "cpu_bound"

services/storage/docker/boot.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ if [ "${STORAGE_WORKER_MODE}" = "true" ]; then
5959
worker --pool=threads \
6060
--loglevel="${SERVER_LOG_LEVEL}" \
6161
--concurrency="${CELERY_CONCURRENCY}" \
62+
--hostname="${STORAGE_WORKER_NAME}" \
6263
--queues="${CELERY_QUEUES:-default}"
6364
else
6465
exec celery \
6566
--app=simcore_service_storage.modules.celery.worker_main:app \
6667
worker --pool=threads \
6768
--loglevel="${SERVER_LOG_LEVEL}" \
6869
--concurrency="${CELERY_CONCURRENCY}" \
70+
--hostname="${STORAGE_WORKER_NAME}" \
6971
--queues="${CELERY_QUEUES:-default}"
7072
fi
7173
else

services/storage/docker/healthcheck.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121

2222
import os
23-
import socket
2423
import subprocess
2524
import sys
2625
from urllib.request import urlopen
@@ -37,6 +36,7 @@
3736

3837
app_settings = ApplicationSettings.create_from_envs()
3938

39+
4040
def _is_celery_worker_healthy():
4141
assert app_settings.STORAGE_CELERY
4242
broker_url = app_settings.STORAGE_CELERY.CELERY_RABBIT_BROKER.dsn
@@ -50,7 +50,7 @@ def _is_celery_worker_healthy():
5050
"inspect",
5151
"ping",
5252
"--destination",
53-
"celery@" + socket.gethostname(),
53+
"celery@" + os.getenv("STORAGE_WORKER_NAME", "worker"),
5454
],
5555
capture_output=True,
5656
text=True,

0 commit comments

Comments
 (0)