-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathstart_celery.sh
executable file
·37 lines (29 loc) · 1.18 KB
/
start_celery.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
set -eu
THIS_DIR=$(dirname "$(readlink -f "$0")")
cd "$THIS_DIR"
cd ../app/src
./manage.py migrate
# Default concurrency = 2
CELERY_CONCURRENCY=${CELERY_CONCURRENCY:-2}
# Default loglevel = INFO
CELERY_LOGLEVEL=${CELERY_LOGLEVEL:-INFO}
# below we define two workers types (each may have any concurrency);
# each worker may have its own settings
WORKERS="default weights jobs llm receipts"
OPTIONS="-E -l $CELERY_LOGLEVEL --pidfile=/tmp/celery-validator-%n.pid --logfile=/tmp/celery-validator-%n.log"
# shellcheck disable=SC2086
celery -A compute_horde_validator multi start $WORKERS $OPTIONS \
-Q:default default --autoscale:generic=$CELERY_CONCURRENCY \
-Q:weights weights --autoscale:weights=$CELERY_CONCURRENCY \
-Q:jobs jobs --autoscale:jobs=$CELERY_CONCURRENCY \
-Q:scores scores --autoscale:scores=$CELERY_CONCURRENCY \
-Q:receipts receipts --autoscale:receipts=$CELERY_CONCURRENCY
# shellcheck disable=2064
trap "celery multi stop $WORKERS $OPTIONS; exit 0" INT TERM
tail -f /tmp/celery-validator-*.log &
# check celery status periodically to exit if it crashed
while true; do
sleep 30
celery -A compute_horde_validator status > /dev/null 2>&1 || exit 1
done