summaryrefslogtreecommitdiffstats
path: root/plugin/pluginenv/environment.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/pluginenv/environment.go')
-rw-r--r--plugin/pluginenv/environment.go12
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
}