forked from gunjeetgulatigit/nameko-devex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepinio.run.bash
executable file
·33 lines (25 loc) · 1.02 KB
/
epinio.run.bash
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
#!/bin/bash
WORKSPACE=${1:-"workspace"}
echo -e "\nRetrieving environment variables from Epinio services...\n"
AMQP_URI="amqp://user:$(cat /configurations/*-rabbitmq/rabbitmq-password)@$WORKSPACE-rabbit-rabbitmq.$WORKSPACE.svc.cluster.local:5672"
export AMQP_URI
POSTGRES_URI="postgresql://postgres:$(cat /configurations/*-postgresql/postgres-password)@$WORKSPACE-postgres-postgresql.$WORKSPACE.svc.cluster.local:5432/devex"
export POSTGRES_URI
REDIS_URI="redis://$WORKSPACE-redis-redis.$WORKSPACE.svc.cluster.local:6379"
export REDIS_URI
# Comment the line below if you don't want to use FastAPI.
#export FASTAPI=X
# Database creation
python -c """
import psycopg2 as db
from urllib.parse import urlparse
result = urlparse('${POSTGRES_URI}')
username = result.username
password = result.password
database = result.path[1:]
hostname = result.hostname
port = result.port
con=db.connect(dbname='postgres',host=hostname,user=username,password=password)
con.autocommit=True;con.cursor().execute('CREATE DATABASE devex')
"""
./run.sh "$@"