Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce PGBOUNCER_CONNECT_QUERY parameter to configure connect_query setting #95

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@ and [stunnel](http://linux.die.net/man/8/stunnel) configurations to see what set
- `ENABLE_STUNNEL_AMAZON_RDS_FIX` Default is unset. Set this var if you are connecting to an Amazon RDS instance of postgres.
Adds `options = NO_TICKET` which is documented to make stunnel work correctly after a dyno resumes from sleep. Otherwise, the dyno will lose connectivity to RDS.
- `PGBOUNCER_IGNORE_STARTUP_PARAMETERS` Adds parameters to ignore when pgbouncer is starting. Some postgres libraries, like Go's pq, append this parameter, making it impossible to use this buildpack. Default is empty and the most common ignored parameter is `extra_float_digits`. Multiple parameters can be seperated via commas. Example: `PGBOUNCER_IGNORE_STARTUP_PARAMETERS="extra_float_digits, some_other_param"`
- `PGBOUNCER_CONNECT_QUERY` The query to be executed on newly created connections. This is useful for setting things like `statement_timeout`. e.g. `PGBOUNCER_CONNECT_QUERY="set statement_timeout to 10000"`

For more info, see [CONTRIBUTING.md](CONTRIBUTING.md)
7 changes: 6 additions & 1 deletion bin/gen-pgbouncer-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,13 @@ EOFEOF
"$DB_USER" "$DB_MD5_PASS"
EOFEOF

CONNECT_QUERY_PARAM=''
if [[ "$PGBOUNCER_CONNECT_QUERY" ]]; then
CONNECT_QUERY_PARAM="connect_query='${PGBOUNCER_CONNECT_QUERY//\'/\'\'}'"
fi

cat >> /app/vendor/pgbouncer/pgbouncer.ini << EOFEOF
$CLIENT_DB_NAME= dbname=$DB_NAME port=610${n}
$CLIENT_DB_NAME= dbname=$DB_NAME port=610${n} $CONNECT_QUERY_PARAM
EOFEOF

let "n += 1"
Expand Down