mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Do not require server restart when enabling/disabling plugins (#7592)
This commit is contained in:
@@ -394,12 +394,14 @@ func (a *App) RemovePlugin(id string) *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) InitPlugins(pluginPath, webappPath string) {
|
||||
a.InitBuiltInPlugins()
|
||||
|
||||
if !utils.IsLicensed() || !*utils.License().Features.FutureFeatures || !*utils.Cfg.PluginSettings.Enable {
|
||||
return
|
||||
}
|
||||
|
||||
if a.PluginEnv != nil {
|
||||
return
|
||||
}
|
||||
|
||||
l4g.Info("Starting up plugins")
|
||||
|
||||
err := os.Mkdir(pluginPath, 0744)
|
||||
@@ -485,9 +487,13 @@ func (a *App) ShutDownPlugins() {
|
||||
if a.PluginEnv == nil {
|
||||
return
|
||||
}
|
||||
|
||||
l4g.Info("Shutting down plugins")
|
||||
|
||||
for _, err := range a.PluginEnv.Shutdown() {
|
||||
l4g.Error(err.Error())
|
||||
}
|
||||
utils.RemoveConfigListener(a.PluginConfigListenerId)
|
||||
a.PluginConfigListenerId = ""
|
||||
a.PluginEnv = nil
|
||||
}
|
||||
|
||||
@@ -76,8 +76,18 @@ func runServer(configFileLocation string) {
|
||||
a.LoadLicense()
|
||||
}
|
||||
|
||||
a.InitBuiltInPlugins()
|
||||
|
||||
if webappDir, ok := utils.FindDir(model.CLIENT_DIR); ok {
|
||||
a.InitPlugins("plugins", webappDir+"/plugins")
|
||||
|
||||
utils.AddConfigListener(func(prevCfg *model.Config, cfg *model.Config) {
|
||||
if !*prevCfg.PluginSettings.Enable && *cfg.PluginSettings.Enable {
|
||||
a.InitPlugins("plugins", webappDir+"/plugins")
|
||||
} else if *prevCfg.PluginSettings.Enable && !*cfg.PluginSettings.Enable {
|
||||
a.ShutDownPlugins()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
l4g.Error("Unable to find webapp directory, could not initialize plugins")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user