Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiprocess RQ workers (using supervisor) #4371

Merged
merged 11 commits into from
Jan 1, 2020
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ RUN apt-get update && \
libssl-dev \
default-libmysqlclient-dev \
freetds-dev \
libsasl2-dev && \
libsasl2-dev \
supervisor && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand Down
12 changes: 10 additions & 2 deletions bin/docker-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ dev_scheduler() {
worker() {
echo "Starting RQ worker..."

exec /app/manage.py rq worker $QUEUES
start_worker
}

dev_worker() {
echo "Starting dev RQ worker..."

exec watchmedo auto-restart --directory=./redash/ --pattern=*.py --recursive -- ./manage.py rq worker $QUEUES
start_worker "watchmedo auto-restart --directory=./redash/ --pattern=*.py --recursive -- "
}

start_worker() {
export EXECUTION_PREFIX=$1
export WORKERS_COUNT=${WORKERS_COUNT:-2}
export QUEUES=${QUEUES:-}

supervisord -c worker.conf
}

dev_celery_worker() {
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ services:
target: /app
depends_on:
- server
tty: true
environment:
PYTHONUNBUFFERED: 0
REDASH_LOG_LEVEL: "INFO"
Expand Down
17 changes: 17 additions & 0 deletions worker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[supervisord]
logfile=/tmp/supervisord.log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update this to stdout as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pidfile=/tmp/supervisord.pid
nodaemon=true

[program:worker]
command=%(ENV_EXECUTION_PREFIX)s ./manage.py rq worker %(ENV_QUEUES)s
process_name=%(program_name)s-%(process_num)s
numprocs=%(ENV_WORKERS_COUNT)s
directory=/app
stopsignal=TERM
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0