diff options
author | Chris <ccbrown112@gmail.com> | 2018-01-11 15:23:41 -0600 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2018-01-11 13:23:41 -0800 |
commit | 1d9efd0e39a9663bb2fbf52b3353fe21ac3b6954 (patch) | |
tree | 5518bf9683e2fcbcb6b4e0acd3643a3146574ec4 /cmd/platform | |
parent | 6990d052d5e95295e729aae28a0d30bfdcb98573 (diff) | |
download | chat-1d9efd0e39a9663bb2fbf52b3353fe21ac3b6954.tar.gz chat-1d9efd0e39a9663bb2fbf52b3353fe21ac3b6954.tar.bz2 chat-1d9efd0e39a9663bb2fbf52b3353fe21ac3b6954.zip |
Remove global config watcher (#8080)
* remove global config watcher
* keep config watcher disabled for tests
* compile fix
* fix resource leak
Diffstat (limited to 'cmd/platform')
-rw-r--r-- | cmd/platform/init.go | 8 | ||||
-rw-r--r-- | cmd/platform/server.go | 39 |
2 files changed, 20 insertions, 27 deletions
diff --git a/cmd/platform/init.go b/cmd/platform/init.go index 7d5593821..ef3d78692 100644 --- a/cmd/platform/init.go +++ b/cmd/platform/init.go @@ -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() } diff --git a/cmd/platform/server.go b/cmd/platform/server.go index e240c6583..cdf12cf71 100644 --- a/cmd/platform/server.go +++ b/cmd/platform/server.go @@ -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 +func runServer(configFileLocation string, disableConfigWatch bool) { + options := []app.Option{app.ConfigFile(configFileLocation)} + if disableConfigWatch { + options = append(options, app.DisableConfigWatch) } - model.AppErrorInit(utils.T) - if err := utils.InitAndLoadConfig(configFileLocation); err != nil { - l4g.Exit("Unable to load Mattermost configuration file: ", err) - return - } - - 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" { |