* remove global config watcher

* keep config watcher disabled for tests

* compile fix

* fix resource leak
Этот коммит содержится в:
Chris
2018-01-11 15:23:41 -06:00
коммит произвёл Corey Hulen
родитель 6990d052d5
Коммит 1d9efd0e39
12 изменённых файлов: 215 добавлений и 175 удалений

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

@@ -31,13 +31,13 @@ func initDBCommandContext(configFileLocation string) (*app.App, error) {
}
model.AppErrorInit(utils.T)
if err := utils.InitAndLoadConfig(configFileLocation); err != nil {
utils.ConfigureCmdLineLog()
a, err := app.New(app.ConfigFile(configFileLocation))
if err != nil {
return nil, err
}
utils.ConfigureCmdLineLog()
a := app.New(app.ConfigFile(configFileLocation))
if model.BuildEnterpriseReady == "true" {
a.LoadLicense()
}

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

@@ -35,30 +35,26 @@ func runServerCmd(cmd *cobra.Command, args []string) error {
return err
}
utils.CfgDisableConfigWatch, _ = cmd.Flags().GetBool("disableconfigwatch")
disableConfigWatch, _ := cmd.Flags().GetBool("disableconfigwatch")
runServer(config)
runServer(config, disableConfigWatch)
return nil
}
func runServer(configFileLocation string) {
if err := utils.TranslationsPreInit(); err != nil {
l4g.Exit("Unable to load Mattermost configuration file: ", err)
return
}
model.AppErrorInit(utils.T)
if err := utils.InitAndLoadConfig(configFileLocation); err != nil {
l4g.Exit("Unable to load Mattermost configuration file: ", err)
return
func runServer(configFileLocation string, disableConfigWatch bool) {
options := []app.Option{app.ConfigFile(configFileLocation)}
if disableConfigWatch {
options = append(options, app.DisableConfigWatch)
}
if err := utils.InitTranslations(utils.Cfg.LocalizationSettings); err != nil {
l4g.Exit("Unable to load Mattermost translation files: %v", err)
a, err := app.New(options...)
if err != nil {
l4g.Error(err.Error())
return
}
defer a.Shutdown()
utils.TestConnection(utils.Cfg)
utils.TestConnection(a.Config())
pwd, _ := os.Getwd()
l4g.Info(utils.T("mattermost.current_version"), model.CurrentVersion, model.BuildNumber, model.BuildDate, model.BuildHash, model.BuildHashEnterprise)
@@ -66,15 +62,12 @@ func runServer(configFileLocation string) {
l4g.Info(utils.T("mattermost.working_dir"), pwd)
l4g.Info(utils.T("mattermost.config_file"), utils.FindConfigFile(configFileLocation))
a := app.New(app.ConfigFile(configFileLocation))
defer a.Shutdown()
backend, err := a.FileBackend()
if err == nil {
err = backend.TestConnection()
backend, appErr := a.FileBackend()
if appErr == nil {
appErr = backend.TestConnection()
}
if err != nil {
l4g.Error("Problem with file storage settings: " + err.Error())
if appErr != nil {
l4g.Error("Problem with file storage settings: " + appErr.Error())
}
if model.BuildEnterpriseReady == "true" {