Added config for database max connections
This commit is contained in:
parent
bbd90eb976
commit
522e647db0
3 changed files with 7 additions and 1 deletions
|
@ -45,6 +45,9 @@ database:
|
||||||
Path: "./vikunja.db"
|
Path: "./vikunja.db"
|
||||||
# Whether to show mysql queries or not. Useful for debugging.
|
# Whether to show mysql queries or not. Useful for debugging.
|
||||||
showqueries: "false"
|
showqueries: "false"
|
||||||
|
# Sets the max open connections to the database. Only used when using mysql.
|
||||||
|
openconnections: 100
|
||||||
|
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
# If cache is enabled or not
|
# If cache is enabled or not
|
||||||
|
|
|
@ -27,6 +27,7 @@ func InitConfig() (err error) {
|
||||||
viper.SetDefault("database.database", "vikunja")
|
viper.SetDefault("database.database", "vikunja")
|
||||||
viper.SetDefault("database.path", "./vikunja.db")
|
viper.SetDefault("database.path", "./vikunja.db")
|
||||||
viper.SetDefault("database.showqueries", false)
|
viper.SetDefault("database.showqueries", false)
|
||||||
|
viper.SetDefault("database.openconnections", 100)
|
||||||
// Cacher
|
// Cacher
|
||||||
viper.SetDefault("cache.enabled", false)
|
viper.SetDefault("cache.enabled", false)
|
||||||
viper.SetDefault("cache.type", "memory")
|
viper.SetDefault("cache.type", "memory")
|
||||||
|
|
|
@ -27,7 +27,9 @@ func getEngine() (*xorm.Engine, error) {
|
||||||
viper.GetString("database.password"),
|
viper.GetString("database.password"),
|
||||||
viper.GetString("database.host"),
|
viper.GetString("database.host"),
|
||||||
viper.GetString("database.database"))
|
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
|
// Otherwise use sqlite
|
||||||
|
|
Loading…
Reference in a new issue