diff --git a/pkg/plugins/app_plugin.go b/pkg/plugins/app_plugin.go index a6cbc3e279e..495b3a56a6f 100644 --- a/pkg/plugins/app_plugin.go +++ b/pkg/plugins/app_plugin.go @@ -2,12 +2,15 @@ package plugins import ( "encoding/json" + "path/filepath" "strings" "github.com/gosimple/slug" "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/plugins/backendplugin" + "github.com/grafana/grafana/pkg/plugins/backendplugin/grpcplugin" "github.com/grafana/grafana/pkg/setting" + "github.com/grafana/grafana/pkg/util/errutil" ) type AppPluginCss struct { @@ -21,6 +24,8 @@ type AppPlugin struct { FoundChildPlugins []*PluginInclude `json:"-"` Pinned bool `json:"-"` + + Executable string `json:"executable,omitempty"` } // AppPluginRoute describes a plugin route that is defined in @@ -67,6 +72,15 @@ func (app *AppPlugin) Load(decoder *json.Decoder, base *PluginBase, backendPlugi return err } + if app.Backend { + cmd := ComposePluginStartCommand(app.Executable) + fullpath := filepath.Join(app.PluginDir, cmd) + factory := grpcplugin.NewBackendPlugin(app.Id, fullpath, grpcplugin.PluginStartFuncs{}) + if err := backendPluginManager.Register(app.Id, factory); err != nil { + return errutil.Wrapf(err, "failed to register backend plugin") + } + } + Apps[app.Id] = app return nil }