mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-06 13:43:09 -06:00
Setup tweaks
This commit is contained in:
parent
32f699c254
commit
622df1a8fc
|
|
@ -194,17 +194,20 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...Base
|
|||
// have a separate database config of their own.
|
||||
var db *sql.DB
|
||||
var writer sqlutil.Writer
|
||||
if cfg.Global.DatabaseOptions != nil && isMonolith {
|
||||
if cfg.Global.DatabaseOptions.ConnectionString != "" && isMonolith {
|
||||
switch {
|
||||
case cfg.Global.DatabaseOptions.ConnectionString.IsSQLite():
|
||||
writer = sqlutil.NewExclusiveWriter()
|
||||
default:
|
||||
writer = sqlutil.NewDummyWriter()
|
||||
}
|
||||
db, err = sqlutil.Open(cfg.Global.DatabaseOptions, writer)
|
||||
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.Info("Not using global database connection pool")
|
||||
}
|
||||
|
||||
// Ideally we would only use SkipClean on routes which we know can allow '/' but due to
|
||||
|
|
@ -249,7 +252,7 @@ func (b *BaseDendrite) Close() error {
|
|||
// DatabaseConnection sets up a new database connection if appropriate,
|
||||
// or returns the global connection pool if not (monolith mode only).
|
||||
func (b *BaseDendrite) DatabaseConnection(dbProperties *config.DatabaseOptions, writer sqlutil.Writer) (*sql.DB, sqlutil.Writer, error) {
|
||||
if dbProperties != nil || b == nil {
|
||||
if dbProperties.ConnectionString != "" || b == nil {
|
||||
db, err := sqlutil.Open(dbProperties, writer)
|
||||
return db, writer, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ type Global struct {
|
|||
// connections will be used instead. This way we don't have to manage connection
|
||||
// counts on a per-component basis, but can instead do it for the entire monolith.
|
||||
// In a polylith deployment, this will be ignored.
|
||||
DatabaseOptions *DatabaseOptions `yaml:"database"`
|
||||
DatabaseOptions DatabaseOptions `yaml:"database"`
|
||||
|
||||
// The server name to delegate server-server communications to, with optional port
|
||||
WellKnownServerName string `yaml:"well_known_server_name"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue