Unverified Commit 3890bc70 authored by Harrison Healey's avatar Harrison Healey Committed by GitHub
Browse files

PLT-8289 Added ability to change location of client plugins (4.4) (#7943)

parent 753386c2
......@@ -71,18 +71,14 @@ func runServer(configFileLocation string) {
a.LoadLicense()
}
if webappDir, ok := utils.FindDir(model.CLIENT_DIR); ok {
a.InitPlugins(*a.Config().PluginSettings.Directory, webappDir+"/plugins")
utils.AddConfigListener(func(prevCfg, cfg *model.Config) {
if *cfg.PluginSettings.Enable {
a.InitPlugins(*cfg.PluginSettings.Directory, webappDir+"/plugins")
} else {
a.ShutDownPlugins()
}
})
} else {
l4g.Error("Unable to find webapp directory, could not initialize plugins")
}
a.InitPlugins(*a.Config().PluginSettings.Directory, *a.Config().PluginSettings.ClientDirectory)
utils.AddConfigListener(func(prevCfg, cfg *model.Config) {
if *cfg.PluginSettings.Enable {
a.InitPlugins(*cfg.PluginSettings.Directory, *a.Config().PluginSettings.ClientDirectory)
} else {
a.ShutDownPlugins()
}
})
a.StartServer()
api4.Init(a, a.Srv.Router, false)
......
......@@ -338,6 +338,7 @@
"Enable": true,
"EnableUploads": false,
"Directory": "./plugins",
"ClientDirectory": "./client/plugins",
"Plugins": {},
"PluginStates": {}
}
......
......@@ -148,7 +148,8 @@ const (
DATA_RETENTION_SETTINGS_DEFAULT_FILE_RETENTION_DAYS = 365
DATA_RETENTION_SETTINGS_DEFAULT_DELETION_JOB_START_TIME = "02:00"
PLUGIN_SETTINGS_DEFAULT_DIRECTORY = "./plugins"
PLUGIN_SETTINGS_DEFAULT_DIRECTORY = "./plugins"
PLUGIN_SETTINGS_DEFAULT_CLIENT_DIRECTORY = "./client/plugins"
)
type ServiceSettings struct {
......@@ -518,11 +519,12 @@ type PluginState struct {
}
type PluginSettings struct {
Enable *bool
EnableUploads *bool
Directory *string
Plugins map[string]interface{}
PluginStates map[string]*PluginState
Enable *bool
EnableUploads *bool
Directory *string
ClientDirectory *string
Plugins map[string]interface{}
PluginStates map[string]*PluginState
}
type ConfigFunc func() *Config
......@@ -1495,6 +1497,14 @@ func (o *Config) SetDefaults() {
*o.PluginSettings.Directory = PLUGIN_SETTINGS_DEFAULT_DIRECTORY
}
if o.PluginSettings.ClientDirectory == nil {
o.PluginSettings.ClientDirectory = NewString(PLUGIN_SETTINGS_DEFAULT_CLIENT_DIRECTORY)
}
if *o.PluginSettings.ClientDirectory == "" {
*o.PluginSettings.ClientDirectory = PLUGIN_SETTINGS_DEFAULT_CLIENT_DIRECTORY
}
if o.PluginSettings.Plugins == nil {
o.PluginSettings.Plugins = make(map[string]interface{})
}
......
......@@ -26,7 +26,7 @@ func Init(api3 *api.API) {
l4g.Debug("Using client directory at %v", staticDir)
staticHandler := staticHandler(http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))
pluginHandler := pluginHandler(api3.App.Config, http.StripPrefix("/static/plugins/", http.FileServer(http.Dir(staticDir+"plugins/"))))
pluginHandler := pluginHandler(api3.App.Config, http.StripPrefix("/static/plugins/", http.FileServer(http.Dir(*api3.App.Config().PluginSettings.ClientDirectory))))
if *api3.App.Config().ServiceSettings.WebserverMode == "gzip" {
staticHandler = gziphandler.GzipHandler(staticHandler)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment