Skip to content

Commit b26eb67

Browse files
authored
Merge pull request #65 from tyler-8/db_options
Add support for configuring database CONN_MAX_AGE
2 parents 7e763f8 + 7e9f618 commit b26eb67

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ section for more information on configuring the database.
147147

148148
Note that these are used to configure `DATABASE` in `configuration.py`.
149149

150+
[source,yaml]
151+
----
152+
netbox_database_conn_age: 300
153+
----
154+
155+
To configure Netbox to keep database connections open longer than a single requests,
156+
set `netbox_database_conn_age` to your preferred maximum connection age, in seconds.
157+
300 seconds (5 minutes) is typically a good number to start with.
158+
150159
[source,yaml]
151160
----
152161
netbox_redis_host: 127.0.0.1

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ netbox_database_user: netbox
2020
#netbox_database_host: localhost
2121
netbox_database_port: 5432
2222
#netbox_database_socket: /var/run/postgresql
23+
netbox_database_conn_age: 0
2324

2425
netbox_redis_host: 127.0.0.1
2526
netbox_redis_port: 6379

templates/configuration.py.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ DATABASE = {
1111
{% else %}
1212
'HOST': '{{ netbox_database_socket }}',
1313
{% endif %}
14+
'CONN_MAX_AGE': {{ netbox_database_conn_age }},
1415
}
1516

16-
REDIS = {
17+
REDIS = {
1718
'HOST': '{{ netbox_redis_host }}',
1819
'PORT': '{{ netbox_redis_port }}',
1920
'PASSWORD': '{{ netbox_redis_password }}',

0 commit comments

Comments
 (0)