ToolJet/server/entrypoint.sh
Adish M 4cd8839d44
Fix for entrypoint.sh file to take default port value 5432 in database_url (#5824)
* Fix for entrypoint.sh file take default port value 5432 in database_url

* Added information about database_url in docs

* mentioning what variable needs to be given when passing string

* fix for lint issue in ci

* fixing syntax errors
2023-03-24 20:54:40 +05:30

25 lines
606 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" | awk -F[@/:] '{print $4}')
PG_PORT=$(echo "$DATABASE_URL" | awk -F'[@/]' '{split($5,a,":"); print a[2] ? a[2] : "5432"}')
./server/scripts/wait-for-it.sh "$PG_HOST:$PG_PORT" --strict --timeout=300 -- $SETUP_CMD
fi
exec "$@"