Skip to content

Commit 217d6a5

Browse files
feat: docker boot
1 parent 0e890d7 commit 217d6a5

File tree

2 files changed

+58
-17
lines changed

2 files changed

+58
-17
lines changed

services/docker-compose.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ services:
11401140
init: true
11411141
hostname: "{{.Node.Hostname}}-{{.Task.Slot}}"
11421142

1143-
environment:
1143+
environment: &notifications_environment
11441144
LOG_FILTER_MAPPING: ${LOG_FILTER_MAPPING}
11451145
LOG_FORMAT_LOCAL_DEV_ENABLED: ${LOG_FORMAT_LOCAL_DEV_ENABLED}
11461146

@@ -1163,6 +1163,21 @@ services:
11631163
TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT: ${TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT}
11641164
TRACING_OPENTELEMETRY_COLLECTOR_PORT: ${TRACING_OPENTELEMETRY_COLLECTOR_PORT}
11651165

1166+
no-worker:
1167+
image: ${DOCKER_REGISTRY:-itisfoundation}/notifications:${DOCKER_IMAGE_TAG:-master-github-latest}
1168+
init: true
1169+
hostname: "no-worker-{{.Node.Hostname}}-{{.Task.Slot}}"
1170+
environment:
1171+
<<: *notifications_environment
1172+
REDIS_HOST: ${REDIS_HOST}
1173+
REDIS_PORT: ${REDIS_PORT}
1174+
REDIS_SECURE: ${REDIS_SECURE}
1175+
REDIS_USER: ${REDIS_USER}
1176+
REDIS_PASSWORD: ${REDIS_PASSWORD}
1177+
NOTIFICATIONS_WORKER_NAME: "no-worker-{{.Node.Hostname}}-{{.Task.Slot}}-{{.Task.ID}}"
1178+
NOTIFICATIONS_WORKER_MODE: "true"
1179+
CELERY_CONCURRENCY: 100
1180+
11661181
dask-sidecar:
11671182
image: ${DOCKER_REGISTRY:-itisfoundation}/dask-sidecar:${DOCKER_IMAGE_TAG:-latest}
11681183
init: true

services/notifications/docker/boot.sh

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,49 @@ APP_LOG_LEVEL=${LOGLEVEL:-${LOG_LEVEL:-${LOGLEVEL:-INFO}}}
4747
SERVER_LOG_LEVEL=$(echo "${APP_LOG_LEVEL}" | tr '[:upper:]' '[:lower:]')
4848
echo "$INFO" "Log-level app/server: $APP_LOG_LEVEL/$SERVER_LOG_LEVEL"
4949

50-
if [ "${SC_BOOT_MODE}" = "debug" ]; then
51-
reload_dir_packages=$(find /devel/packages -maxdepth 3 -type d -path "*/src/*" ! -path "*.*" -exec echo '--reload-dir {} \' \;)
50+
if [ "${NOTIFICATIONS_WORKER_MODE}" = "true" ]; then
51+
if [ "${SC_BOOT_MODE}" = "debug" ]; then
52+
exec watchmedo auto-restart \
53+
--directory /devel/packages \
54+
--directory services/notifications \
55+
--pattern "*.py" \
56+
--recursive \
57+
-- \
58+
celery \
59+
--app=simcore_service_notifications.modules.celery.worker_main:the_celery_app \
60+
worker --pool=threads \
61+
--loglevel="${SERVER_LOG_LEVEL}" \
62+
--concurrency="${CELERY_CONCURRENCY}" \
63+
--hostname="${NOTIFICATIONS_WORKER_NAME}" \
64+
--queues="${CELERY_QUEUES:-default}"
65+
else
66+
exec celery \
67+
--app=simcore_service_notifications.modules.celery.worker_main:the_celery_app \
68+
worker --pool=threads \
69+
--loglevel="${SERVER_LOG_LEVEL}" \
70+
--concurrency="${CELERY_CONCURRENCY}" \
71+
--hostname="${NOTIFICATIONS_WORKER_NAME}" \
72+
--queues="${CELERY_QUEUES:-default}"
73+
fi
74+
else
75+
if [ "${SC_BOOT_MODE}" = "debug" ]; then
76+
reload_dir_packages=$(find /devel/packages -maxdepth 3 -type d -path "*/src/*" ! -path "*.*" -exec echo '--reload-dir {} \' \;)
5277

53-
exec sh -c "
54-
cd services/notifications/src/simcore_service_notifications && \
55-
python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:${NOTIFICATIONS_REMOTE_DEBUGGING_PORT} -m uvicorn main:the_app \
78+
exec sh -c "
79+
cd services/notifications/src/simcore_service_notifications && \
80+
python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:${NOTIFICATIONS_REMOTE_DEBUGGING_PORT} -m uvicorn main:the_app \
81+
--host 0.0.0.0 \
82+
--port 8000 \
83+
--reload \
84+
$reload_dir_packages
85+
--reload-dir . \
86+
--log-level \"${SERVER_LOG_LEVEL}\"
87+
"
88+
else
89+
exec uvicorn simcore_service_notifications.main:the_app \
5690
--host 0.0.0.0 \
5791
--port 8000 \
58-
--reload \
59-
$reload_dir_packages
60-
--reload-dir . \
61-
--log-level \"${SERVER_LOG_LEVEL}\"
62-
"
63-
else
64-
exec uvicorn simcore_service_notifications.main:the_app \
65-
--host 0.0.0.0 \
66-
--port 8000 \
67-
--log-level "${SERVER_LOG_LEVEL}" \
68-
--no-access-log
92+
--log-level "${SERVER_LOG_LEVEL}" \
93+
--no-access-log
94+
fi
6995
fi

0 commit comments

Comments
 (0)