Update config

This commit is contained in:
Neil Alexander 2022-05-03 12:31:57 +01:00
parent 496dd3a36d
commit 7abaada35e
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 18 additions and 13 deletions

View file

@ -54,6 +54,16 @@ global:
# considered valid by other homeservers. # considered valid by other homeservers.
key_validity_period: 168h0m0s key_validity_period: 168h0m0s
# Global database connection pool, for PostgreSQL monolith deployments only. If
# this section is populated then you can omit the "database" blocks in all other
# sections. For polylith deployments, or monolith deployments using SQLite databases,
# you must configure the "database" block for each component instead.
# database:
# connection_string: postgres://user:pass@hostname/database?sslmode=disable
# max_open_conns: 100
# max_idle_conns: 5
# conn_max_lifetime: -1
# The server name to delegate server-server communications to, with optional port # The server name to delegate server-server communications to, with optional port
# e.g. localhost:443 # e.g. localhost:443
well_known_server_name: "" well_known_server_name: ""

View file

@ -195,21 +195,16 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...Base
var db *sql.DB var db *sql.DB
var writer sqlutil.Writer var writer sqlutil.Writer
if cfg.Global.DatabaseOptions.ConnectionString != "" { if cfg.Global.DatabaseOptions.ConnectionString != "" {
if isMonolith { if !isMonolith {
switch {
case cfg.Global.DatabaseOptions.ConnectionString.IsSQLite():
writer = sqlutil.NewExclusiveWriter()
default:
writer = sqlutil.NewDummyWriter()
}
db, err = sqlutil.Open(&cfg.Global.DatabaseOptions, writer)
if err != nil {
logrus.WithError(err).Panic("Failed to set up global database connections")
}
logrus.Info("Using global database connection pool")
} else {
logrus.Panic("Using a global database connection pool is not supported in polylith deployments") logrus.Panic("Using a global database connection pool is not supported in polylith deployments")
} }
if cfg.Global.DatabaseOptions.ConnectionString.IsSQLite() {
logrus.Panic("Using a global database connection pool is not supported with SQLite databases")
}
if db, err = sqlutil.Open(&cfg.Global.DatabaseOptions, sqlutil.NewDummyWriter()); err != nil {
logrus.WithError(err).Panic("Failed to set up global database connections")
}
logrus.Debug("Using global database connection pool")
} }
// Ideally we would only use SkipClean on routes which we know can allow '/' but due to // Ideally we would only use SkipClean on routes which we know can allow '/' but due to