Parcourir la source

fix(renderer): add .exe for phantomjs on windows

closes #3657
bergquist il y a 9 ans
Parent
commit
6a7e9134a5
2 fichiers modifiés avec 9 ajouts et 1 suppressions
  1. 1 0
      CHANGELOG.md
  2. 8 1
      pkg/components/renderer/renderer.go

+ 1 - 0
CHANGELOG.md

@@ -26,6 +26,7 @@
 * **InfluxDB**: Fix for InfluxDB and table panel when using Format As Table and having group by time, fixes [#3928](https://github.com/grafana/grafana/issues/3928)
 * **Panel Time shift**: Fix for panel time range and using dashboard times liek `Today` and `This Week`, fixes [#3941](https://github.com/grafana/grafana/issues/3941)
 * **Row repeat**: Repeated rows will now appear next to each other and not by the bottom of the dashboard, fixes [#3942](https://github.com/grafana/grafana/issues/3942)
+* **Png renderer**: Fix for phantomjs path on windows, fixes [#3657](https://github.com/grafana/grafana/issues/3657)
 
 # 2.6.1 (unrelased, 2.6.x branch)
 

+ 8 - 1
pkg/components/renderer/renderer.go

@@ -5,6 +5,7 @@ import (
 	"os"
 	"os/exec"
 	"path/filepath"
+	"runtime"
 	"time"
 
 	"github.com/grafana/grafana/pkg/log"
@@ -21,7 +22,13 @@ type RenderOpts struct {
 
 func RenderToPng(params *RenderOpts) (string, error) {
 	log.Info("PhantomRenderer::renderToPng url %v", params.Url)
-	binPath, _ := filepath.Abs(filepath.Join(setting.PhantomDir, "phantomjs"))
+
+	var executable = "phantomjs"
+	if runtime.GOOS == "windows" {
+		executable = executable + ".exe"
+	}
+
+	binPath, _ := filepath.Abs(filepath.Join(setting.PhantomDir, executable))
 	scriptPath, _ := filepath.Abs(filepath.Join(setting.PhantomDir, "render.js"))
 	pngPath, _ := filepath.Abs(filepath.Join(setting.ImagesDir, util.GetRandomString(20)))
 	pngPath = pngPath + ".png"