Commit 43073da7 by bergquist

feat(renderer): add timeout for the renderer api

closes #4325
parent 0b6fee13
......@@ -31,6 +31,7 @@ func RenderToPng(c *middleware.Context) {
Width: queryReader.Get("width", "800"),
Height: queryReader.Get("height", "400"),
SessionId: c.Session.ID(),
Timeout: queryReader.Get("timeout", "15"),
}
renderOpts.Url = setting.ToAbsUrl(renderOpts.Url)
......
......@@ -11,6 +11,7 @@ import (
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
"strconv"
)
type RenderOpts struct {
......@@ -18,6 +19,7 @@ type RenderOpts struct {
Width string
Height string
SessionId string
Timeout string
}
func RenderToPng(params *RenderOpts) (string, error) {
......@@ -60,8 +62,13 @@ func RenderToPng(params *RenderOpts) (string, error) {
close(done)
}()
timeout, err := strconv.Atoi(params.Timeout)
if err != nil {
timeout = 15
}
select {
case <-time.After(15 * time.Second):
case <-time.After(time.Duration(timeout) * time.Second):
if err := cmd.Process.Kill(); err != nil {
log.Error(4, "failed to kill: %v", err)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment