-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·40 lines (35 loc) · 946 Bytes
/
start.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
#!/bin/bash
echo "Criando atalho e inserindo no bashrc"
echo alias shell="'python src/manage.py shell'" >> ~/.bashrc
echo alias tests="'pytest'" >> ~/.bashrc
echo "Esperando o banco de dados conectar"
postgres_ready() {
python3 << END
import sys
import psycopg2
import os
try:
conn = psycopg2.connect(
dbname=os.environ.get('POSTGRES_NAME'),
user=os.environ.get('POSTGRES_USER'),
password=os.environ.get('POSTGRES_PASSWORD'),
host=os.environ.get('POSTGRES_HOST')
)
except psycopg2.OperationalError:
sys.exit(-1)
sys.exit(0)
END
}
until postgres_ready; do
>&2 echo "PostgreSQL não está disponível ainda - Espere..."
sleep 1
done
echo "Rodando as migrações"
python src/manage.py migrate
echo "Rodando o servidor"
if [ "$ENVIRONMENT" = "development" ]
then
uvicorn app:app --reload --host 0.0.0.0 --port 5000 --log-level debug
else
uvicorn app:app --host 0.0.0.0 --port 5000 --log-level info
fi