mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 01:25:16 +00:00
109 lines
2.4 KiB
Bash
Executable File
109 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
worker() {
|
|
WORKERS_COUNT=${WORKERS_COUNT:-2}
|
|
QUEUES=${QUEUES:-queries,scheduled_queries,celery,schemas}
|
|
|
|
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
|
|
}
|
|
|
|
scheduler() {
|
|
WORKERS_COUNT=${WORKERS_COUNT:-1}
|
|
QUEUES=${QUEUES:-celery}
|
|
SCHEDULE_DB=${SCHEDULE_DB:-celerybeat-schedule}
|
|
|
|
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
|
|
}
|
|
|
|
server() {
|
|
exec /usr/local/bin/gunicorn -b 0.0.0.0:5000 --name redash -w${REDASH_WEB_WORKERS:-4} redash.wsgi:app
|
|
}
|
|
|
|
create_db() {
|
|
exec /app/manage.py database create_tables
|
|
}
|
|
|
|
celery_healthcheck() {
|
|
exec /usr/local/bin/celery inspect ping --app=redash.worker -d celery@$HOSTNAME
|
|
}
|
|
|
|
help() {
|
|
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 "celery_healthcheck -- runs a Celery healthcheck. Useful for Docker's HEALTHCHECK mechanism."
|
|
echo ""
|
|
echo "shell -- open shell"
|
|
echo "dev_server -- start Flask development server with debugger and auto reload"
|
|
echo "debug -- start Flask development server with remote debugger via ptvsd"
|
|
echo "create_db -- create database tables"
|
|
echo "manage -- CLI to manage redash"
|
|
echo "tests -- run tests"
|
|
}
|
|
|
|
tests() {
|
|
export REDASH_DATABASE_URL="postgresql://postgres@postgres/tests"
|
|
|
|
if [ $# -eq 0 ]; then
|
|
TEST_ARGS=tests/
|
|
else
|
|
TEST_ARGS=$@
|
|
fi
|
|
exec pytest $TEST_ARGS
|
|
}
|
|
|
|
case "$1" in
|
|
worker)
|
|
shift
|
|
worker
|
|
;;
|
|
server)
|
|
shift
|
|
server
|
|
;;
|
|
scheduler)
|
|
shift
|
|
scheduler
|
|
;;
|
|
dev_server)
|
|
export FLASK_DEBUG=1
|
|
exec /app/manage.py runserver --debugger --reload -h 0.0.0.0
|
|
;;
|
|
debug)
|
|
export FLASK_DEBUG=1
|
|
export REMOTE_DEBUG=1
|
|
exec /app/manage.py runserver --debugger --no-reload -h 0.0.0.0
|
|
;;
|
|
shell)
|
|
exec /app/manage.py shell
|
|
;;
|
|
create_db)
|
|
create_db
|
|
;;
|
|
manage)
|
|
shift
|
|
exec /app/manage.py $*
|
|
;;
|
|
tests)
|
|
shift
|
|
tests $@
|
|
;;
|
|
help)
|
|
shift
|
|
help
|
|
;;
|
|
*)
|
|
exec "$@"
|
|
;;
|
|
esac
|
|
|