PLT-6317 disable file watcher while running from makefile (#6103)
* PLT-6317 disable file watcher while running from make file * Removing debug stmt
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
3207886514
Коммит
acc991dea1
2
Makefile
2
Makefile
@@ -417,7 +417,7 @@ run-server: prepare-enterprise start-docker
|
|||||||
@echo Running mattermost for development
|
@echo Running mattermost for development
|
||||||
|
|
||||||
mkdir -p $(BUILD_WEBAPP_DIR)/dist/files
|
mkdir -p $(BUILD_WEBAPP_DIR)/dist/files
|
||||||
$(GO) run $(GOFLAGS) $(GO_LINKER_FLAGS) ./cmd/platform/*.go &
|
$(GO) run $(GOFLAGS) $(GO_LINKER_FLAGS) ./cmd/platform/*.go --disableconfigwatch &
|
||||||
|
|
||||||
run-cli: prepare-enterprise start-docker
|
run-cli: prepare-enterprise start-docker
|
||||||
@echo Running mattermost for development
|
@echo Running mattermost for development
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ func SaveConfig(cfg *model.Config) *model.AppError {
|
|||||||
return model.NewLocAppError("saveConfig", "ent.cluster.save_config.error", nil, "")
|
return model.NewLocAppError("saveConfig", "ent.cluster.save_config.error", nil, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
//oldCfg := utils.Cfg
|
|
||||||
utils.DisableConfigWatch()
|
utils.DisableConfigWatch()
|
||||||
utils.SaveConfig(utils.CfgFileName, cfg)
|
utils.SaveConfig(utils.CfgFileName, cfg)
|
||||||
utils.LoadConfig(utils.CfgFileName)
|
utils.LoadConfig(utils.CfgFileName)
|
||||||
@@ -150,6 +149,7 @@ func SaveConfig(cfg *model.Config) *model.AppError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// oldCfg := utils.Cfg
|
||||||
// Future feature is to sync the configuration files
|
// Future feature is to sync the configuration files
|
||||||
// if einterfaces.GetClusterInterface() != nil {
|
// if einterfaces.GetClusterInterface() != nil {
|
||||||
// err := einterfaces.GetClusterInterface().ConfigChanged(cfg, oldCfg, true)
|
// err := einterfaces.GetClusterInterface().ConfigChanged(cfg, oldCfg, true)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ func doLoadConfig(filename string) (err string) {
|
|||||||
utils.LoadConfig(filename)
|
utils.LoadConfig(filename)
|
||||||
utils.InitializeConfigWatch()
|
utils.InitializeConfigWatch()
|
||||||
utils.EnableConfigWatch()
|
utils.EnableConfigWatch()
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ func main() {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.PersistentFlags().StringP("config", "c", "config.json", "Configuration file to use.")
|
rootCmd.PersistentFlags().StringP("config", "c", "config.json", "Configuration file to use.")
|
||||||
|
rootCmd.PersistentFlags().Bool("disableconfigwatch", false, "When set config.json will not be loaded from disk when the file is changed.")
|
||||||
|
|
||||||
resetCmd.Flags().Bool("confirm", false, "Confirm you really want to delete everything and a DB backup has been performed.")
|
resetCmd.Flags().Bool("confirm", false, "Confirm you really want to delete everything and a DB backup has been performed.")
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ func runServerCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utils.CfgDisableConfigWatch, _ = cmd.Flags().GetBool("disableconfigwatch")
|
||||||
|
|
||||||
runServer(config)
|
runServer(config)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ var Cfg *model.Config = &model.Config{}
|
|||||||
var CfgDiagnosticId = ""
|
var CfgDiagnosticId = ""
|
||||||
var CfgHash = ""
|
var CfgHash = ""
|
||||||
var CfgFileName string = ""
|
var CfgFileName string = ""
|
||||||
|
var CfgDisableConfigWatch = false
|
||||||
var ClientCfg map[string]string = map[string]string{}
|
var ClientCfg map[string]string = map[string]string{}
|
||||||
var originalDisableDebugLvl l4g.Level = l4g.DEBUG
|
var originalDisableDebugLvl l4g.Level = l4g.DEBUG
|
||||||
var siteURL = ""
|
var siteURL = ""
|
||||||
@@ -178,6 +179,10 @@ func InitializeConfigWatch() {
|
|||||||
cfgMutex.Lock()
|
cfgMutex.Lock()
|
||||||
defer cfgMutex.Unlock()
|
defer cfgMutex.Unlock()
|
||||||
|
|
||||||
|
if CfgDisableConfigWatch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if watcher == nil {
|
if watcher == nil {
|
||||||
var err error
|
var err error
|
||||||
watcher, err = fsnotify.NewWatcher()
|
watcher, err = fsnotify.NewWatcher()
|
||||||
@@ -215,11 +220,13 @@ func EnableConfigWatch() {
|
|||||||
cfgMutex.Lock()
|
cfgMutex.Lock()
|
||||||
defer cfgMutex.Unlock()
|
defer cfgMutex.Unlock()
|
||||||
|
|
||||||
configFile := filepath.Clean(CfgFileName)
|
|
||||||
configDir, _ := filepath.Split(configFile)
|
|
||||||
|
|
||||||
if watcher != nil {
|
if watcher != nil {
|
||||||
watcher.Add(configDir)
|
configFile := filepath.Clean(CfgFileName)
|
||||||
|
configDir, _ := filepath.Split(configFile)
|
||||||
|
|
||||||
|
if watcher != nil {
|
||||||
|
watcher.Add(configDir)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user