Skip to content

Commit

Permalink
Updates to docker-entrypoint for worker and scheduler (#364)
Browse files Browse the repository at this point in the history
* Use --max-tasks-per-child as per celery documentation

* Set --max-memory-per-child to 1/4th of total system memory

* Split exec command over multiple lines

* Fix memory variable typo
  • Loading branch information
jasonthomas authored and Allen Short committed Mar 26, 2019
1 parent 4c70fe6 commit f6f519c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/docker-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ worker() {
/app/manage.py db upgrade
WORKERS_COUNT=${WORKERS_COUNT:-2}
QUEUES=${QUEUES:-queries,scheduled_queries,celery,schemas}
MAX_MEMORY=$(($(/usr/bin/awk '/MemTotal/ {print $2}' /proc/meminfo)/4))

echo "Starting $WORKERS_COUNT workers for queues: $QUEUES..."
exec /usr/local/bin/celery worker --app=redash.worker -c$WORKERS_COUNT -Q$QUEUES -linfo --maxtasksperchild=10 -Ofair
exec /usr/local/bin/celery worker --app=redash.worker -c$WORKERS_COUNT -Q$QUEUES -linfo --max-tasks-per-child=10 --max-memory-per-child=$MAX_MEMORY -Ofair

}

scheduler() {
Expand All @@ -18,7 +20,7 @@ scheduler() {

echo "Starting scheduler and $WORKERS_COUNT workers for queues: $QUEUES..."

exec /usr/local/bin/celery worker --app=redash.worker --beat -s$SCHEDULE_DB -c$WORKERS_COUNT -Q$QUEUES -linfo --maxtasksperchild=10 -Ofair
exec /usr/local/bin/celery worker --app=redash.worker --beat -s$SCHEDULE_DB -c$WORKERS_COUNT -Q$QUEUES -linfo --max-tasks-per-child=10 -Ofair
}

server() {
Expand Down

0 comments on commit f6f519c

Please sign in to comment.