Skip to content

Commit

Permalink
feat: use symlink approach for single process celery
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Aug 15, 2024
1 parent 265bf5c commit c5a1c3b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions start
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,16 @@ if [ "$1" = "runserver" ] ; then
fi
ln -s "/etc/supervisor/conf.d/$WEBLATE_SERVICE.conf" "$SUPERVISOR_CONF"
else
ln -s /etc/supervisor/conf.d/*.conf "$SUPERVISOR_CONF"
# Symlink all non-celery services
find /etc/supervisor/conf.d -type f ! -name 'celery-*.conf' -print0 | xargs -0 -I '{}' ln -s '{}' "$SUPERVISOR_CONF"

if [ "${CELERY_SINGLE_PROCESS:-0}" -eq 1 ] ; then
# Symlink single process service only
ln -s /etc/supervisor/conf.d/celery-signle.conf "$SUPERVISOR_CONF"
else
# Symlink all celery services but the single process
find /etc/supervisor/conf.d -type f -name 'celery-*.conf' ! -name 'celery-single.conf' -print0 | xargs -0 -I '{}' ln -s '{}' "$SUPERVISOR_CONF"
fi
fi

if [ $DO_MIGRATE -eq 1 ] ; then
Expand Down Expand Up @@ -269,13 +278,6 @@ set_real_ip_from 0.0.0.0/0;
mkdir -p /tmp/nginx
envsubst "\$WEBLATE_URL_PREFIX:\$WEBLATE_REALIP:\$CLIENT_MAX_BODY_SIZE" < $template > /tmp/nginx/weblate-site.conf

if [ "${CELERY_SINGLE_PROCESS:-0}" -eq 1 ] ; then
# remove all celery-*.conf except celery-single.conf
find /etc/supervisor/conf.d -type f -name 'celery-*.conf' ! -name 'celery-single.conf' -delete \;
else
rm -f /etc/supervisor/conf.d/celery-single.conf
fi

# Calculate number of processes, at least 2, at most 4, depending on CPU cores
if [ -z "$WEBLATE_WORKERS" ] ; then
PROCESSORS=$(nproc)
Expand Down

0 comments on commit c5a1c3b

Please sign in to comment.