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

closes #3657
This commit is contained in:
bergquist
2016-02-16 10:09:26 +01:00
parent 48c5e26acd
commit 6a7e9134a5
2 changed files with 9 additions and 1 deletions

View File

@@ -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"