PLT-8289 Added ability to change location of client plugins (#7942)
Этот коммит содержится в:
коммит произвёл
Chris
родитель
154a502f8e
Коммит
36777057f2
@@ -75,18 +75,14 @@ func runServer(configFileLocation string) {
|
|||||||
a.LoadLicense()
|
a.LoadLicense()
|
||||||
}
|
}
|
||||||
|
|
||||||
if webappDir, ok := utils.FindDir(model.CLIENT_DIR); ok {
|
a.InitPlugins(*a.Config().PluginSettings.Directory, *a.Config().PluginSettings.ClientDirectory)
|
||||||
a.InitPlugins(*a.Config().PluginSettings.Directory, webappDir+"/plugins")
|
utils.AddConfigListener(func(prevCfg, cfg *model.Config) {
|
||||||
utils.AddConfigListener(func(prevCfg, cfg *model.Config) {
|
if *cfg.PluginSettings.Enable {
|
||||||
if *cfg.PluginSettings.Enable {
|
a.InitPlugins(*cfg.PluginSettings.Directory, *a.Config().PluginSettings.ClientDirectory)
|
||||||
a.InitPlugins(*cfg.PluginSettings.Directory, webappDir+"/plugins")
|
} else {
|
||||||
} else {
|
a.ShutDownPlugins()
|
||||||
a.ShutDownPlugins()
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
} else {
|
|
||||||
l4g.Error("Unable to find webapp directory, could not initialize plugins")
|
|
||||||
}
|
|
||||||
|
|
||||||
a.StartServer()
|
a.StartServer()
|
||||||
api4.Init(a, a.Srv.Router, false)
|
api4.Init(a, a.Srv.Router, false)
|
||||||
|
|||||||
@@ -349,6 +349,7 @@
|
|||||||
"Enable": true,
|
"Enable": true,
|
||||||
"EnableUploads": false,
|
"EnableUploads": false,
|
||||||
"Directory": "./plugins",
|
"Directory": "./plugins",
|
||||||
|
"ClientDirectory": "./client/plugins",
|
||||||
"Plugins": {},
|
"Plugins": {},
|
||||||
"PluginStates": {}
|
"PluginStates": {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,8 @@ const (
|
|||||||
DATA_RETENTION_SETTINGS_DEFAULT_FILE_RETENTION_DAYS = 365
|
DATA_RETENTION_SETTINGS_DEFAULT_FILE_RETENTION_DAYS = 365
|
||||||
DATA_RETENTION_SETTINGS_DEFAULT_DELETION_JOB_START_TIME = "02:00"
|
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 {
|
type ServiceSettings struct {
|
||||||
@@ -1476,11 +1477,12 @@ type PluginState struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PluginSettings struct {
|
type PluginSettings struct {
|
||||||
Enable *bool
|
Enable *bool
|
||||||
EnableUploads *bool
|
EnableUploads *bool
|
||||||
Directory *string
|
Directory *string
|
||||||
Plugins map[string]interface{}
|
ClientDirectory *string
|
||||||
PluginStates map[string]*PluginState
|
Plugins map[string]interface{}
|
||||||
|
PluginStates map[string]*PluginState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PluginSettings) SetDefaults() {
|
func (s *PluginSettings) SetDefaults() {
|
||||||
@@ -1500,6 +1502,14 @@ func (s *PluginSettings) SetDefaults() {
|
|||||||
*s.Directory = PLUGIN_SETTINGS_DEFAULT_DIRECTORY
|
*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 {
|
if s.Plugins == nil {
|
||||||
s.Plugins = make(map[string]interface{})
|
s.Plugins = make(map[string]interface{})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func Init(api3 *api.API) {
|
|||||||
l4g.Debug("Using client directory at %v", staticDir)
|
l4g.Debug("Using client directory at %v", staticDir)
|
||||||
|
|
||||||
staticHandler := staticHandler(http.StripPrefix("/static/", http.FileServer(http.Dir(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" {
|
if *api3.App.Config().ServiceSettings.WebserverMode == "gzip" {
|
||||||
staticHandler = gziphandler.GzipHandler(staticHandler)
|
staticHandler = gziphandler.GzipHandler(staticHandler)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user