mirror of
https://github.com/grafana/grafana.git
synced 2025-09-27 08:14:11 +08:00
execute process directly instead of creating sub shell
This commit is contained in:
@ -24,17 +24,19 @@ type BackendDatasource struct {
|
|||||||
client *plugin.Client
|
client *plugin.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var handshakeConfig = plugin.HandshakeConfig{
|
||||||
|
ProtocolVersion: 1,
|
||||||
|
MagicCookieKey: "GRAFANA_BACKEND_DATASOURCE",
|
||||||
|
MagicCookieValue: "55d2200a-6492-493a-9353-73b728d468aa",
|
||||||
|
}
|
||||||
|
|
||||||
func (p *BackendDatasource) initBackendPlugin(log log.Logger) error {
|
func (p *BackendDatasource) initBackendPlugin(log log.Logger) error {
|
||||||
p.log = log.New("plugin-id", p.Id)
|
p.log = log.New("plugin-id", p.Id)
|
||||||
|
|
||||||
p.client = plugin.NewClient(&plugin.ClientConfig{
|
p.client = plugin.NewClient(&plugin.ClientConfig{
|
||||||
HandshakeConfig: plugin.HandshakeConfig{
|
HandshakeConfig: handshakeConfig,
|
||||||
ProtocolVersion: 1,
|
|
||||||
MagicCookieKey: "BASIC_PLUGIN",
|
|
||||||
MagicCookieValue: "hello",
|
|
||||||
},
|
|
||||||
Plugins: map[string]plugin.Plugin{p.Id: &shared.TsdbPluginImpl{}},
|
Plugins: map[string]plugin.Plugin{p.Id: &shared.TsdbPluginImpl{}},
|
||||||
Cmd: exec.Command("sh", "-c", path.Join(p.PluginDir, p.Executable)),
|
Cmd: exec.Command(path.Join(p.PluginDir, p.Executable)),
|
||||||
AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},
|
AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},
|
||||||
Logger: backend.LogWrapper{Logger: p.log},
|
Logger: backend.LogWrapper{Logger: p.log},
|
||||||
})
|
})
|
||||||
|
@ -64,6 +64,7 @@ func (tw *TsdbWrapper) Query(ctx context.Context, ds *models.DataSource, query *
|
|||||||
|
|
||||||
res := &tsdb.Response{
|
res := &tsdb.Response{
|
||||||
Message: pbres.Message,
|
Message: pbres.Message,
|
||||||
|
Results: map[string]*tsdb.QueryResult{},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, r := range pbres.Results {
|
for _, r := range pbres.Results {
|
||||||
|
Reference in New Issue
Block a user