forked from ByCodersTec/desafio-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·34 lines (30 loc) · 892 Bytes
/
start.sh
File metadata and controls
executable file
·34 lines (30 loc) · 892 Bytes
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
#!/bin/bash
echo "Espera o POSTGRESQL inicializar e insere as variáveis de ambiente"
postgres_ready() {
python3 << END
import sys
import psycopg2
import os
try:
psycopg2.connect(
dbname=os.environ.get("POSTGRES_DB", "bycoders-db"),
user=os.environ.get("POSTGRES_USER", "bycoders"),
password=os.environ.get("POSTGRES_PASSWORD", "bycoders"),
host=os.environ.get("POSTGRES_HOST", "postgres"),
port=5432
)
except psycopg2.OperationalError as error:
print(error)
sys.exit(-1)
sys.exit(0)
END
}
until postgres_ready; do
>&2 echo "Postgresql não está acessivel - Espere..."
sleep 1
done
echo "Criando as migrações e inserindo no banco de dados PostgreSQL"
python3 manage.py makemigrations
python3 manage.py migrate
echo "Rodando o servidor"
gunicorn config.wsgi --bind 0.0.0.0:8000 --reload --graceful-timeout=900 --timeout=900 --workers 1