forked from alphagov/notifications-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·95 lines (73 loc) · 2.12 KB
/
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#Cater for specific concurrency level
if [ "$1" == "api-worker-periodic" ] || [ "$1" == "api-worker-broadcasts" ]
then
CONCURRENCY=2
elif [ "$1" == "api-worker-sender-letters" ]
then
CONCURRENCY=3
else
CONCURRENCY=4
fi
# Define a common command prefix
WORKER_CMD="celery --quiet -A run_celery.notify_celery worker --logfile=/dev/null --concurrency=$CONCURRENCY"
COMMON_CMD="$WORKER_CMD -Q"
if [ "$1" == "worker" ]
then
exec $WORKER_CMD
elif [ "$1" == "api" ]
then
exec gunicorn -c /home/vcap/app/gunicorn_config.py application
elif [ "$1" == "api-local" ]
then
exec flask run --host 0.0.0.0 --port $PORT
elif [ "$1" == "migration" ]
then
exec flask db upgrade
elif [ "$1" == "api-worker-retry-tasks" ]
then
exec $COMMON_CMD retry-tasks
elif [ "$1" == "api-worker-letters" ]
then
exec $COMMON_CMD create-letters-pdf-tasks,letter-tasks
elif [ "$1" == "api-worker-jobs" ]
then
exec $COMMON_CMD database-tasks,job-tasks
elif [ "$1" == "api-worker-research" ]
then
exec $COMMON_CMD research-mode-tasks
elif [ "$1" == "api-worker-sender" ]
then
exec $COMMON_CMD send-sms-tasks,send-email-tasks
elif [ "$1" == "api-worker-sender-letters" ]
then
exec $COMMON_CMD send-letter-tasks
elif [ "$1" == "api-worker-periodic" ]
then
exec $COMMON_CMD periodic-tasks
elif [ "$1" == "api-worker-reporting" ]
then
exec $COMMON_CMD reporting-tasks
# Only consume the notify-internal-tasks queue on this app so that Notify messages are processed as a priority
elif [ "$1" == "api-worker-internal" ]
then
exec $COMMON_CMD notify-internal-tasks
elif [ "$1" == "api-worker-broadcasts" ]
then
exec $COMMON_CMD broadcast-tasks
elif [ "$1" == "api-worker-receipts" ]
then
exec $COMMON_CMD ses-callbacks,sms-callbacks
elif [ "$1" == "api-worker-service-callbacks" ]
then
exec $COMMON_CMD service-callbacks,service-callbacks-retry
elif [ "$1" == "api-worker-save-api-notifications" ]
then
exec $COMMON_CMD save-api-email-tasks,save-api-sms-tasks
elif [ "$1" == "celery-beat" ]
then
exec celery -A run_celery.notify_celery beat --loglevel=INFO
else
echo -e "'\033[31m'FATAL: missing argument'\033[0m'" && exit 1
exit 1
fi