MM-20865 - Demo Plugin: Enabling and disabling demo plugin generates "connection is shutdown" error (#13604)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
mattermod
родитель
28ec291910
Коммит
30061b2285
@@ -271,6 +271,11 @@ func (env *Environment) Activate(id string) (manifest *model.Manifest, activated
|
||||
if err != nil {
|
||||
return nil, false, errors.Wrapf(err, "unable to start plugin: %v", id)
|
||||
}
|
||||
|
||||
if err := sup.Hooks().OnActivate(); err != nil {
|
||||
sup.Shutdown()
|
||||
return nil, false, err
|
||||
}
|
||||
rp.supervisor = sup
|
||||
env.registeredPlugins.Store(id, rp)
|
||||
|
||||
@@ -313,6 +318,8 @@ func (env *Environment) Deactivate(id string) bool {
|
||||
rp.supervisor.Shutdown()
|
||||
}
|
||||
|
||||
env.registeredPlugins.Delete(id)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -333,7 +340,7 @@ func (env *Environment) Shutdown() {
|
||||
env.registeredPlugins.Range(func(key, value interface{}) bool {
|
||||
rp := value.(registeredPlugin)
|
||||
|
||||
if rp.supervisor == nil {
|
||||
if rp.supervisor == nil || !env.IsActive(rp.BundleInfo.Manifest.Id) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -434,7 +441,7 @@ func (env *Environment) UnpackWebappBundle(id string) (*model.Manifest, error) {
|
||||
func (env *Environment) HooksForPlugin(id string) (Hooks, error) {
|
||||
if p, ok := env.registeredPlugins.Load(id); ok {
|
||||
rp := p.(registeredPlugin)
|
||||
if rp.supervisor != nil {
|
||||
if rp.supervisor != nil && env.IsActive(id) {
|
||||
return rp.supervisor.Hooks(), nil
|
||||
}
|
||||
}
|
||||
@@ -442,7 +449,7 @@ func (env *Environment) HooksForPlugin(id string) (Hooks, error) {
|
||||
return nil, fmt.Errorf("plugin not found: %v", id)
|
||||
}
|
||||
|
||||
// RunMultiPluginHook invokes hookRunnerFunc for each plugin that implements the given hookId.
|
||||
// RunMultiPluginHook invokes hookRunnerFunc for each active plugin that implements the given hookId.
|
||||
//
|
||||
// If hookRunnerFunc returns false, iteration will not continue. The iteration order among active
|
||||
// plugins is not specified.
|
||||
@@ -450,14 +457,11 @@ func (env *Environment) RunMultiPluginHook(hookRunnerFunc func(hooks Hooks) bool
|
||||
env.registeredPlugins.Range(func(key, value interface{}) bool {
|
||||
rp := value.(registeredPlugin)
|
||||
|
||||
if rp.supervisor == nil || !rp.supervisor.Implements(hookId) {
|
||||
if rp.supervisor == nil || !rp.supervisor.Implements(hookId) || !env.IsActive(rp.BundleInfo.Manifest.Id) {
|
||||
return true
|
||||
}
|
||||
if !hookRunnerFunc(rp.supervisor.Hooks()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
return hookRunnerFunc(rp.supervisor.Hooks())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -92,11 +92,6 @@ func newSupervisor(pluginInfo *model.BundleInfo, parentLogger *mlog.Logger, apiI
|
||||
}
|
||||
}
|
||||
|
||||
err = sup.Hooks().OnActivate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &sup, nil
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user