redash/bin/docker-entrypoint

66 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/bin/bash
set -e
worker() {
WORKERS_COUNT=${WORKERS_COUNT:-2}
QUEUES=${QUEUES:-queries,scheduled_queries,celery}
echo "Starting $WORKERS_COUNT workers for queues: $QUEUES..."
exec sudo -E -u redash /usr/local/bin/celery worker --app=redash.worker -c$WORKERS_COUNT -Q$QUEUES -linfo --maxtasksperchild=10 -Ofair
}
scheduler() {
WORKERS_COUNT=${WORKERS_COUNT:-1}
QUEUES=${QUEUES:-celery}
echo "Starting scheduler and $WORKERS_COUNT workers for queues: $QUEUES..."
exec sudo -E -u redash /usr/local/bin/celery worker --app=redash.worker --beat -c$WORKERS_COUNT -Q$QUEUES -linfo --maxtasksperchild=10 -Ofair
}
2017-01-18 13:20:46 +00:00
server() {
exec sudo -E -u redash /usr/local/bin/gunicorn -b 0.0.0.0:5000 --name redash -w4 redash:app
}
help() {
2017-01-18 13:20:46 +00:00
echo "Redash Docker."
echo ""
echo "Usage:"
echo ""
echo "server -- start Redash server (with gunicorn)"
echo "worker -- start Celery worker"
echo "scheduler -- start Celery worker with a beat (scheduler) process"
echo ""
echo "shell -- open shell"
echo "dev_server -- start Flask development server with debugger and auto reload"
echo "create_db -- create database tables"
}
case "$1" in
worker)
shift
worker
;;
2017-01-18 13:20:46 +00:00
server)
shift
2017-01-18 13:20:46 +00:00
server
;;
scheduler)
shift
scheduler
;;
dev_server)
2017-01-18 13:20:46 +00:00
exec sudo -E -u redash /app/manage.py runserver --debugger --reload -h 0.0.0.0
;;
shell)
2017-01-18 13:20:46 +00:00
exec sudo -E -u redash /app/manage.py shell
;;
create_db)
exec sudo -E -u redash /app/manage.py database create_tables
;;
*)
help
;;
esac