-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
48 lines (42 loc) · 1.11 KB
/
entrypoint.sh
File metadata and controls
48 lines (42 loc) · 1.11 KB
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
#!/bin/bash
# if any of the commands in your code fails for any reason, the entire script fails
set -o errexit
# fail exit if one of your pipe command fails
set -o pipefail
app=$(echo $APP | tr '[:upper:]' '[:lower:]')
ENVS=("APP" "CELERY_BROKER_URL" "CELERY_RESULT_BACKEND")
# check if all ENV var are set
for env in ${ENVS[@]}; do
if [ -z "${!env}" ]; then
echo "Missing $env env variable"
exit 1
fi
done
export DISABLE_DOTENV=True
# switch
case $app in
"worker")
echo "Starting worker"
exec celery -A fob_api.worker worker --loglevel=info -E $@
;;
"beat")
echo "Starting beat"
exec celery -A fob_api.worker beat --loglevel=info $@
;;
"flower")
echo "Starting flower"
exec celery -A fob_api.worker flower $@
;;
"api")
echo "Starting web"
# make migrations
alembic upgrade head
exec uvicorn fob_api.main:app --host 0.0.0.0 --port 8000 $@
;;
*)
echo "Invalid APP env variable"
echo "Please set APP env variable to one of the following values: worker, beat, flower, api"
exit 1
;;
esac
echo "Container exited (why?) :3"