chore: Restart celery worker on source changes (#5749)
* chore: Restart celery worker on Python source change * chore: Debounce celery restarts, only watch ietf dir
This commit is contained in:
parent
2ca4f7beaf
commit
b7dd8b9b95
|
@ -17,4 +17,7 @@ COPY requirements.txt /tmp/pip-tmp/
|
||||||
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt
|
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt
|
||||||
RUN rm -rf /tmp/pip-tmp
|
RUN rm -rf /tmp/pip-tmp
|
||||||
|
|
||||||
ENTRYPOINT [ "/docker-init.sh" ]
|
# Add watchmedo utility for dev containers
|
||||||
|
RUN pip3 --disable-pip-version-check --no-cache-dir install watchdog[watchmedo]
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/docker-init.sh" ]
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#
|
#
|
||||||
# DEBUG_TERM_TIMING - if non-empty, writes debug messages during shutdown after a TERM signal
|
# DEBUG_TERM_TIMING - if non-empty, writes debug messages during shutdown after a TERM signal
|
||||||
#
|
#
|
||||||
|
# DEV_MODE - if non-empty, restart celery worker on Python file change
|
||||||
|
#
|
||||||
WORKSPACEDIR="/workspace"
|
WORKSPACEDIR="/workspace"
|
||||||
CELERY_ROLE="${CELERY_ROLE:-worker}"
|
CELERY_ROLE="${CELERY_ROLE:-worker}"
|
||||||
|
|
||||||
|
@ -85,6 +87,18 @@ fi
|
||||||
|
|
||||||
trap 'trap "" TERM; cleanup' TERM
|
trap 'trap "" TERM; cleanup' TERM
|
||||||
# start celery in the background so we can trap the TERM signal
|
# start celery in the background so we can trap the TERM signal
|
||||||
celery --app="${CELERY_APP:-ietf}" "${CELERY_OPTS[@]}" "$@" &
|
if [[ -n "${DEV_MODE}" ]]; then
|
||||||
celery_pid=$!
|
watchmedo auto-restart \
|
||||||
|
--patterns '*.py' \
|
||||||
|
--directory 'ietf' \
|
||||||
|
--recursive \
|
||||||
|
--debounce-interval 5 \
|
||||||
|
-- \
|
||||||
|
celery --app="${CELERY_APP:-ietf}" "${CELERY_OPTS[@]}" "$@" &
|
||||||
|
celery_pid=$!
|
||||||
|
else
|
||||||
|
celery --app="${CELERY_APP:-ietf}" "${CELERY_OPTS[@]}" "$@" &
|
||||||
|
celery_pid=$!
|
||||||
|
fi
|
||||||
|
|
||||||
wait "${celery_pid}"
|
wait "${celery_pid}"
|
||||||
|
|
|
@ -74,6 +74,7 @@ services:
|
||||||
CELERY_APP: ietf
|
CELERY_APP: ietf
|
||||||
CELERY_ROLE: worker
|
CELERY_ROLE: worker
|
||||||
UPDATE_REQUIREMENTS_FROM: requirements.txt
|
UPDATE_REQUIREMENTS_FROM: requirements.txt
|
||||||
|
DEV_MODE: yes
|
||||||
command:
|
command:
|
||||||
- '--loglevel=INFO'
|
- '--loglevel=INFO'
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
Loading…
Reference in a new issue