diff options
author | Martin Kraft <martinkraft@gmail.com> | 2018-05-24 08:40:52 -0400 |
---|---|---|
committer | Martin Kraft <martinkraft@gmail.com> | 2018-05-24 08:40:52 -0400 |
commit | 69304fb54da5300941a49364e4344c2c65e654d6 (patch) | |
tree | de20c2e8a479ae3d13bcd21abc3dff067afa602e /plugin/pluginenv/environment.go | |
parent | e46b94fa66c029b9a493fdc6ff7bcb98e9651568 (diff) | |
parent | 47f3c064db885c2cb2e75c195ea24e2ef687891d (diff) | |
download | chat-69304fb54da5300941a49364e4344c2c65e654d6.tar.gz chat-69304fb54da5300941a49364e4344c2c65e654d6.tar.bz2 chat-69304fb54da5300941a49364e4344c2c65e654d6.zip |
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2
Diffstat (limited to 'plugin/pluginenv/environment.go')
-rw-r--r-- | plugin/pluginenv/environment.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/plugin/pluginenv/environment.go b/plugin/pluginenv/environment.go index 947eda86d..f704aa5bb 100644 --- a/plugin/pluginenv/environment.go +++ b/plugin/pluginenv/environment.go @@ -108,7 +108,7 @@ func (env *Environment) IsPluginActive(pluginId string) bool { } // Activates the plugin with the given id. -func (env *Environment) ActivatePlugin(id string) error { +func (env *Environment) ActivatePlugin(id string, onError func(error)) error { env.mutex.Lock() defer env.mutex.Unlock() @@ -117,7 +117,7 @@ func (env *Environment) ActivatePlugin(id string) error { } if _, ok := env.activePlugins[id]; ok { - return nil + return fmt.Errorf("plugin already active: %v", id) } plugins, err := ScanSearchPath(env.searchPath) if err != nil { @@ -156,6 +156,14 @@ func (env *Environment) ActivatePlugin(id string) error { if err := supervisor.Start(api); err != nil { return errors.Wrapf(err, "unable to start plugin: %v", id) } + if onError != nil { + go func() { + err := supervisor.Wait() + if err != nil { + onError(err) + } + }() + } activePlugin.Supervisor = supervisor } |