mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2025-04-28 02:31:15 +08:00
Add native PgBouncer support to alleviate DB connection limit errors
This commit is contained in:
parent
24233506c4
commit
b664cb33c4
4 changed files with 48 additions and 11 deletions
|
@ -223,16 +223,26 @@ SPECTACULAR_SETTINGS = {
|
|||
|
||||
WSGI_APPLICATION = 'config.wsgi.application'
|
||||
|
||||
# If you're using an external connection bouncer (eg. PgBouncer), server side cursors must be disabled to avoid any issues
|
||||
USE_BOUNCER = get_secret("USE_BOUNCER")
|
||||
if USE_BOUNCER:
|
||||
DISABLE_SERVER_SIDE_CURSORS = True
|
||||
DB_HOST = get_secret("DB_BOUNCER_HOST")
|
||||
DB_PORT = get_secret("DB_BOUNCER_PORT")
|
||||
else:
|
||||
DISABLE_SERVER_SIDE_CURSORS = False
|
||||
DB_HOST = get_secret("DB_HOST")
|
||||
DB_PORT = get_secret("DB_PORT")
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
# Set to True to avoid issues with pgbouncer when pooling connections
|
||||
'DISABLE_SERVER_SIDE_CURSORS': get_secret("DB_DISABLE_SERVER_SIDE_CURSORS"),
|
||||
'DISABLE_SERVER_SIDE_CURSORS': DISABLE_SERVER_SIDE_CURSORS,
|
||||
"NAME": get_secret("DB_DATABASE"),
|
||||
"USER": get_secret("DB_USERNAME"),
|
||||
"PASSWORD": get_secret("DB_PASSWORD"),
|
||||
"HOST": get_secret("DB_HOST"),
|
||||
"PORT": get_secret("DB_PORT"),
|
||||
"HOST": DB_HOST,
|
||||
"PORT": DB_PORT,
|
||||
"OPTIONS": {
|
||||
"sslmode": get_secret("DB_SSL_MODE")
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue