-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathentrypoint.sh
executable file
·43 lines (33 loc) · 974 Bytes
/
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
#!/bin/sh
POSTGRES_SERVER=${POSTGRES_SERVER:-localhost}
POSTGRES_USER=${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-}
EMAILS_ENABLED=${EMAILS_ENABLED:-false}
if [[ ${EMAILS_ENABLED} -eq "true" ]]; then
EMAILS_ENABLED=true
fi
EMAILS_FROM_EMAIL=${EMAILS_FROM_EMAIL:[email protected]}
SMTP_TLS=${SMTP_TLS:-false}
if [[ ${SMTP_TLS} -eq "true" ]]; then
SMTP_TLS=true
fi
SECRET_KEY=${SECRET_KEY:-}
BACKEND_NUM_WORKERS=${BACKEND_NUM_WORKERS:-2}
BACKEND_PORT=${BACKEND_PORT:-8000}
export PGPASSWORD=$POSTGRES_PASSWORD
MAX_RETRIES=10
N_RETRY=1
while ! pg_isready -q -h $POSTGRES_SERVER; do
echo "Could not connect to the database, retrying in a few seconds"
sleep 5
N_RETRY=$(($N_RETRY + 1))
if [[ $N_RETRY -eq $MAX_RETRIES ]]; then
echo "Could not connect to database! Please check your configuration!"
exit
fi
done
uvicorn \
--workers $BACKEND_NUM_WORKERS \
--host 0.0.0.0 \
--port $BACKEND_PORT \
molar.backend.main:app