Skip to content

Commit

Permalink
Update max open and idle postgresql connections. Update changelog.
Browse files Browse the repository at this point in the history
Default max idle connections is documented as 2:
https://golang.org/pkg/database/sql/#DB.SetMaxIdleConns
  • Loading branch information
brocaar committed Sep 27, 2019
1 parent c79b764 commit e841ef3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
13 changes: 9 additions & 4 deletions cmd/loraserver/cmd/configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,19 @@ dsn="{{ .PostgreSQL.DSN }}"
# App Server and / or applying migrations.
automigrate={{ .PostgreSQL.Automigrate }}
# Max open connections in the pool.
# <= 0 means unlimited
# Max open connections.
#
# This sets the max. number of open connections that are allowed in the
# PostgreSQL connection pool (0 = unlimited).
max_open_connections={{ .PostgreSQL.MaxOpenConnections }}
# Max open connections in the pool.
# Zero means defaultMaxIdleConns; negative means 0
# Max idle connections.
#
# This sets the max. number of idle connections in the PostgreSQL connection
# pool (0 = no idle connections are retained).
max_idle_connections={{ .PostgreSQL.MaxIdleConnections }}
# Redis settings
#
# Please note that Redis 2.6.0+ is required.
Expand Down
3 changes: 1 addition & 2 deletions cmd/loraserver/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ func init() {

viper.SetDefault("postgresql.dsn", "postgres://localhost/loraserver_ns?sslmode=disable")
viper.SetDefault("postgresql.automigrate", true)
viper.SetDefault("postgresql.max_open_connections", -1)
viper.SetDefault("postgresql.max_idle_connections", 0)
viper.SetDefault("postgresql.max_idle_connections", 2)

viper.SetDefault("network_server.net_id", "000000")
viper.SetDefault("network_server.band.name", "EU_863_870")
Expand Down
12 changes: 12 additions & 0 deletions docs/content/install/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ dsn="postgres://localhost/loraserver_ns?sslmode=disable"
# App Server and / or applying migrations.
automigrate=true

# Max open connections.
#
# This sets the max. number of open connections that are allowed in the
# PostgreSQL connection pool (0 = unlimited).
max_open_connections=0

# Max idle connections.
#
# This sets the max. number of idle connections in the PostgreSQL connection
# pool (0 = no idle connections are retained).
max_idle_connections=2


# Redis settings
#
Expand Down
4 changes: 4 additions & 0 deletions docs/content/overview/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Next to the already existing `HandleUplinkMetaData` method, this adds a
been extended with more meta-data (e.g. DevEUI, payload size, ...) which can be
used for accounting purposes.

### Improvements

* Add PostgreSQL max open / idle connections settings. ([#437](https://github.com/brocaar/loraserver/pull/437))

### Bugfixes

* Fix unreturned errors. ([#428](https://github.com/brocaar/loraserver/pull/428))
Expand Down

0 comments on commit e841ef3

Please sign in to comment.