1
0
Fork 0

djangoctl: Run separate Celery processes for worker and beat

Signed-off-by: Vasilis Tsiligiannis <acinonyx@openwrt.gr>
environments/stage/deployments/79
Vasilis Tsiligiannis 2018-12-13 00:12:55 +02:00
parent 33ef460052
commit 30c3f39b5b
1 changed files with 15 additions and 5 deletions

View File

@ -20,6 +20,7 @@
MANAGE_CMD="django-admin" MANAGE_CMD="django-admin"
WSGI_SERVER="gunicorn" WSGI_SERVER="gunicorn"
DJANGO_APP="db" DJANGO_APP="db"
CELERY_VAR_RUN="/var/run/celery"
usage() { usage() {
cat <<EOF cat <<EOF
@ -31,7 +32,8 @@ COMMANDS:
apply migrations apply migrations
initialize Load initial fixtures initialize Load initial fixtures
run Run WSGI HTTP server run Run WSGI HTTP server
run_celery Run Celery run_celery [worker|beat]
Run Celery worker or beat
develop [SOURCE_DIR] Run application in development mode, optionally develop [SOURCE_DIR] Run application in development mode, optionally
installing SOURCE_DIR in editable mode installing SOURCE_DIR in editable mode
develop_celery [SOURCE_DIR] develop_celery [SOURCE_DIR]
@ -68,7 +70,15 @@ run() {
} }
run_celery() { run_celery() {
exec celery -A "$DJANGO_APP" worker -B -l INFO case "$1" in
worker|beat)
exec celery -A "$DJANGO_APP" "$1" -l INFO --workdir "$CELERY_VAR_RUN"
;;
*)
usage
exit 1
;;
esac
} }
develop() { develop() {
@ -83,7 +93,7 @@ develop_celery() {
if [ -d "$1" ]; then if [ -d "$1" ]; then
install_editable "$1" install_editable "$1"
fi fi
run_celery exec celery -A "$DJANGO_APP" worker -B -l INFO
} }
initialize() { initialize() {
@ -94,11 +104,11 @@ parse_args() {
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
arg="$1" arg="$1"
case $arg in case $arg in
prepare|run|run_celery|initialize) prepare|run|initialize)
command="$arg" command="$arg"
break break
;; ;;
develop|develop_celery) develop|develop_celery|run_celery)
shift shift
subargs="$1" subargs="$1"
command="$arg" command="$arg"