OP#176 fix envsubst
This commit is contained in:
20
start.sh
20
start.sh
@@ -1,17 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Construct DATABASE_URL from individual vars if not set directly
|
||||
if [[ -z "${DATABASE_URL}" ]]; then
|
||||
if [[ -z "${PG_USER}" || -z "${PG_PASSWORD}" || -z "${PG_HOST}" || -z "${PG_DBNAME}" ]]; then
|
||||
echo "ERROR: DATABASE_URL not set and one of PG_USER/PG_PASSWORD/PG_HOST/PG_DBNAME missing"
|
||||
exit 1
|
||||
fi
|
||||
export DATABASE_URL="postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT:-5432}/${PG_DBNAME}?sslmode=${PG_SSLMODE:-disable}"
|
||||
echo "Constructed DATABASE_URL: ${DATABASE_URL}"
|
||||
if [[ "${DATABASE_URL}" == "" ]]; then
|
||||
echo 'Missing DATABASE_URL'
|
||||
echo 'example -e DATABASE_URL="user=<db user> password=<db user password> host=<db host> port=<db port> database=<db name>"'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Strip single quotes from defaults (Alpine bash keeps them)
|
||||
trap shutdown INT
|
||||
|
||||
function shutdown() {
|
||||
pkill -SIGINT postgresql-prometheus-adapter
|
||||
}
|
||||
|
||||
adapter_send_timeout=$(echo "${adapter_send_timeout:-'30s'}" | tr -d "'")
|
||||
web_listen_address=$(echo "${web_listen_address:-':9201'}" | tr -d "'")
|
||||
web_telemetry_path=$(echo "${web_telemetry_path:-'/metrics'}" | tr -d "'")
|
||||
|
||||
Reference in New Issue
Block a user