ToolJet/server/entrypoint.sh
Adish M 46c134916e
fix for database url (#5756)
* fix for database url

* correction

* debug

* corrections

* corrections

* changes in .env example file

* corrections

* corrections

* changes for TOOLJET_DB_URL

* corrections

* naming corrections
2023-03-20 11:45:00 +05:30

25 lines
672 B
Bash
Executable file

#!/bin/bash
set -e
if [ -d "./server/dist" ]
then
SETUP_CMD='npm run db:setup:prod'
else
SETUP_CMD='npm run db:setup'
fi
if [ -f "./.env" ]
then
declare $(grep -v '^#' ./.env | xargs)
fi
if [ -z "$DATABASE_URL" ]
then
./server/scripts/wait-for-it.sh $PG_HOST:${PG_PORT:-5432} --strict --timeout=300 -- $SETUP_CMD
else
PG_HOST=$(echo "$DATABASE_URL" | sed -e 's/postgres:\/\///' -e 's/\([^@]*@\)\?//' | cut -d ':' -f 1)
PG_PORT=$(echo "$DATABASE_URL" | sed -e 's/postgres:\/\///' -e 's/\([^@]*@\)\?//' | cut -d ':' -f 2 | cut -d '/' -f 1)
./server/scripts/wait-for-it.sh "$PG_HOST:$PG_PORT" --strict --timeout=300 -- $SETUP_CMD
fi
exec "$@"