Skip to content

Add CONNECT_QUERY option #158

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

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 @@ -139,6 +139,7 @@ Some settings are configurable through app config vars at runtime. Refer to the
- `PGBOUNCER_SERVER_RESET_QUERY` Default is empty when pool mode is transaction, and "DISCARD ALL;" when session.
- `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_QUERY_WAIT_TIMEOUT` Default is 120 seconds, helps when the server is down or the database rejects connections for any reason. If this is disabled, clients will be queued infinitely.
- `PGBOUNCER_CONNECT_QUERY` Default is ''.

For more info, see [CONTRIBUTING.md](CONTRIBUTING.md)

Expand Down
9 changes: 8 additions & 1 deletion bin/gen-pgbouncer-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ do
"$DB_USER" "$DB_MD5_PASS"
EOFEOF

if [ -z "$PGBOUNCER_CONNECT_QUERY" ]
then
CONNECT_QUERY_ARG=""
else
CONNECT_QUERY_ARG="connect_query=$PGBOUNCER_CONNECT_QUERY"
fi

cat >> /app/vendor/pgbouncer/pgbouncer.ini << EOFEOF
$CLIENT_DB_NAME= host=$DB_HOST dbname=$DB_NAME port=$DB_PORT
$CLIENT_DB_NAME= host=$DB_HOST dbname=$DB_NAME port=$DB_PORT $CONNECT_QUERY_ARG
EOFEOF

let "n += 1"
Expand Down