Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
05362a96
Commit
05362a96
authored
Dec 22, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugins: restart killed plugins
parent
4aeef320
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
8 deletions
+42
-8
pkg/plugins/backend/log-wrapper.go
+15
-5
pkg/plugins/datasource_plugin.go
+25
-1
pkg/tsdb/models/proxy/datasource_plugin_wrapper.go
+2
-2
No files found.
pkg/plugins/backend/log-wrapper.go
View file @
05362a96
...
...
@@ -11,11 +11,21 @@ type LogWrapper struct {
Logger
glog
.
Logger
}
func
(
lw
LogWrapper
)
Trace
(
msg
string
,
args
...
interface
{})
{}
func
(
lw
LogWrapper
)
Debug
(
msg
string
,
args
...
interface
{})
{}
func
(
lw
LogWrapper
)
Info
(
msg
string
,
args
...
interface
{})
{}
func
(
lw
LogWrapper
)
Warn
(
msg
string
,
args
...
interface
{})
{}
func
(
lw
LogWrapper
)
Error
(
msg
string
,
args
...
interface
{})
{}
func
(
lw
LogWrapper
)
Trace
(
msg
string
,
args
...
interface
{})
{
glog
.
Debug2
(
msg
,
args
...
)
}
func
(
lw
LogWrapper
)
Debug
(
msg
string
,
args
...
interface
{})
{
glog
.
Debug2
(
msg
,
args
...
)
}
func
(
lw
LogWrapper
)
Info
(
msg
string
,
args
...
interface
{})
{
glog
.
Info2
(
msg
,
args
...
)
}
func
(
lw
LogWrapper
)
Warn
(
msg
string
,
args
...
interface
{})
{
glog
.
Warn2
(
msg
,
args
...
)
}
func
(
lw
LogWrapper
)
Error
(
msg
string
,
args
...
interface
{})
{
glog
.
Error2
(
msg
,
args
...
)
}
func
(
lw
LogWrapper
)
IsTrace
()
bool
{
return
true
}
func
(
lw
LogWrapper
)
IsDebug
()
bool
{
return
true
}
...
...
pkg/plugins/datasource_plugin.go
View file @
05362a96
...
...
@@ -9,6 +9,7 @@ import (
"path/filepath"
"runtime"
"strings"
"time"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/models"
...
...
@@ -71,6 +72,13 @@ func buildExecutablePath(pluginDir, executable, os, arch string) string {
func
(
p
*
DataSourcePlugin
)
initBackendPlugin
(
log
log
.
Logger
)
error
{
p
.
log
=
log
.
New
(
"plugin-id"
,
p
.
Id
)
p
.
spawnSubProcess
()
go
p
.
reattachKilledProcess
()
return
nil
}
func
(
p
*
DataSourcePlugin
)
spawnSubProcess
()
error
{
cmd
:=
buildExecutablePath
(
p
.
PluginDir
,
p
.
Executable
,
runtime
.
GOOS
,
runtime
.
GOARCH
)
p
.
client
=
plugin
.
NewClient
(
&
plugin
.
ClientConfig
{
...
...
@@ -94,12 +102,28 @@ func (p *DataSourcePlugin) initBackendPlugin(log log.Logger) error {
plugin
:=
raw
.
(
shared
.
TsdbPlugin
)
tsdb
.
RegisterTsdbQueryEndpoint
(
p
.
Id
,
func
(
dsInfo
*
models
.
DataSource
)
(
tsdb
.
TsdbQueryEndpoint
,
error
)
{
return
&
shared
.
Tsdb
Wrapper
{
TsdbPlugin
:
plugin
},
nil
return
&
shared
.
DatasourcePlugin
Wrapper
{
TsdbPlugin
:
plugin
},
nil
})
return
nil
}
func
(
p
*
DataSourcePlugin
)
reattachKilledProcess
()
{
ticker
:=
time
.
NewTicker
(
time
.
Second
*
1
)
for
{
select
{
case
<-
ticker
.
C
:
if
p
.
client
.
Exited
()
{
err
:=
p
.
spawnSubProcess
()
if
err
!=
nil
{
p
.
log
.
Error
(
"Failed to spawn subprocess"
)
}
}
}
}
}
func
(
p
*
DataSourcePlugin
)
Kill
()
{
if
p
.
client
!=
nil
{
p
.
client
.
Kill
()
...
...
pkg/tsdb/models/proxy/wrapper.go
→
pkg/tsdb/models/proxy/
datasource_plugin_
wrapper.go
View file @
05362a96
...
...
@@ -9,11 +9,11 @@ import (
"golang.org/x/net/context"
)
type
Tsdb
Wrapper
struct
{
type
DatasourcePlugin
Wrapper
struct
{
TsdbPlugin
}
func
(
tw
*
Tsdb
Wrapper
)
Query
(
ctx
context
.
Context
,
ds
*
models
.
DataSource
,
query
*
tsdb
.
TsdbQuery
)
(
*
tsdb
.
Response
,
error
)
{
func
(
tw
*
DatasourcePlugin
Wrapper
)
Query
(
ctx
context
.
Context
,
ds
*
models
.
DataSource
,
query
*
tsdb
.
TsdbQuery
)
(
*
tsdb
.
Response
,
error
)
{
jsonData
,
err
:=
ds
.
JsonData
.
MarshalJSON
()
if
err
!=
nil
{
return
nil
,
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment