-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathcelery-entrypoint.sh
executable file
·57 lines (46 loc) · 1.01 KB
/
celery-entrypoint.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
kill_by_pidfile() {
pidfile="${1}"
if [ -z "${pidfile}" ]
then
return
fi
if [ -f "${pidfile}" ]
then
pid="$(cat "${pidfile}")"
kill -TERM "${pid}"
rm "${pidfile}"
fi
}
shutdown() {
echo "Stopping celery beat" >&2
kill_by_pidfile /run/vp/celery-beat.pid
echo "Stopping celery worker" >&2
kill_by_pidfile /run/vp/celery-worker.pid
}
for sig in HUP INT QUIT FPE SEGV TERM USR1 USR2
do
trap "shutdown ${sig}" "${sig}"
done
# cleanup old PID files
shutdown HUP
echo "Starting celery beat" >&2
python3 -m celery \
--app worker \
beat \
--loglevel INFO \
--pidfile /run/vp/celery-beat.pid \
&
echo "Starting celery worker" >&2
python3 -m celery \
--app worker \
worker \
--loglevel INFO \
--concurrency 2 \
--events \
--statedb /run/vp/celery-worker \
--pidfile /run/vp/celery-worker.pid \
&
wait
echo "End of celery work ... CU next time" >&2
exit 0