PLT-8289 Added ability to change location of client plugins (#7942)
Этот коммит содержится в:
коммит произвёл
Chris
родитель
154a502f8e
Коммит
36777057f2
@@ -75,18 +75,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)
|
||||
|
||||
@@ -349,6 +349,7 @@
|
||||
"Enable": true,
|
||||
"EnableUploads": false,
|
||||
"Directory": "./plugins",
|
||||
"ClientDirectory": "./client/plugins",
|
||||
"Plugins": {},
|
||||
"PluginStates": {}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,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 {
|
||||
@@ -1476,11 +1477,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
|
||||
}
|
||||
|
||||
func (s *PluginSettings) SetDefaults() {
|
||||
@@ -1500,6 +1502,14 @@ func (s *PluginSettings) SetDefaults() {
|
||||
*s.Directory = PLUGIN_SETTINGS_DEFAULT_DIRECTORY
|
||||
}
|
||||
|
||||
if s.ClientDirectory == nil {
|
||||
s.ClientDirectory = NewString(PLUGIN_SETTINGS_DEFAULT_CLIENT_DIRECTORY)
|
||||
}
|
||||
|
||||
if *s.ClientDirectory == "" {
|
||||
*s.ClientDirectory = PLUGIN_SETTINGS_DEFAULT_CLIENT_DIRECTORY
|
||||
}
|
||||
|
||||
if s.Plugins == nil {
|
||||
s.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)
|
||||
|
||||
Ссылка в новой задаче
Block a user