Added config for database max connections

This commit is contained in:
kolaente 2018-10-11 18:39:53 +02:00
parent bbd90eb976
commit 522e647db0
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
3 changed files with 7 additions and 1 deletions

View file

@ -45,6 +45,9 @@ database:
Path: "./vikunja.db"
# Whether to show mysql queries or not. Useful for debugging.
showqueries: "false"
# Sets the max open connections to the database. Only used when using mysql.
openconnections: 100
cache:
# If cache is enabled or not

View file

@ -27,6 +27,7 @@ func InitConfig() (err error) {
viper.SetDefault("database.database", "vikunja")
viper.SetDefault("database.path", "./vikunja.db")
viper.SetDefault("database.showqueries", false)
viper.SetDefault("database.openconnections", 100)
// Cacher
viper.SetDefault("cache.enabled", false)
viper.SetDefault("cache.type", "memory")

View file

@ -27,7 +27,9 @@ func getEngine() (*xorm.Engine, error) {
viper.GetString("database.password"),
viper.GetString("database.host"),
viper.GetString("database.database"))
return xorm.NewEngine("mysql", connStr)
e, err := xorm.NewEngine("mysql", connStr)
e.SetMaxOpenConns(viper.GetInt("database.openconnections"))
return e, err
}
// Otherwise use sqlite