Additional Config Store Cleanup (#16440)

This change addresses a few issues where config stores were not
properly closed when an error was encountered on server startup.
This could result in leaked database connections when dealing with
a database config store.
Этот коммит содержится в:
Gabe Jackson
2020-12-03 10:09:31 -05:00
коммит произвёл GitHub
родитель 9283143c3b
Коммит fe7d9f7643
7 изменённых файлов: 18 добавлений и 4 удалений

Просмотреть файл

@@ -611,7 +611,6 @@ func renameChannelCmdF(command *cobra.Command, args []string) error {
}
func searchChannelCmdF(command *cobra.Command, args []string) error {
a, err := InitDBCommandContextCobra(command)
if err != nil {
return errors.Wrap(err, "failed to InitDBCommandContextCobra")

Просмотреть файл

@@ -13,7 +13,6 @@ import (
func InitDBCommandContextCobra(command *cobra.Command) (*app.App, error) {
a, err := InitDBCommandContext(getConfigDSN(command, config.GetEnvironment()))
if err != nil {
// Returning an error just prints the usage message, so actually panic
panic(err)

Просмотреть файл

@@ -62,6 +62,7 @@ func resetPermissionsCmdF(command *cobra.Command, args []string) error {
if err != nil {
return err
}
defer a.Srv().Shutdown()
confirmFlag, _ := command.Flags().GetBool("confirm")
if !confirmFlag {

Просмотреть файл

@@ -78,6 +78,7 @@ func serverCmdF(command *cobra.Command, args []string) error {
if err != nil {
return errors.Wrap(err, "failed to load configuration")
}
defer configStore.Close()
return runServer(configStore, usedPlatform, interruptChan)
}

Просмотреть файл

@@ -32,6 +32,7 @@ func versionCmdF(command *cobra.Command, args []string) error {
if err != nil {
return err
}
defer a.Srv().Shutdown()
printVersion(a)