From 1a4feddf34f6606939466571c8acb6847e15effa Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 16 May 2019 10:53:22 +0800 Subject: [PATCH] :whale: #296 --- output/run.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/output/run.go b/output/run.go index 52610d6..6f7511a 100644 --- a/output/run.go +++ b/output/run.go @@ -24,6 +24,7 @@ import ( "strings" "time" + "github.com/b3log/wide/conf" "github.com/b3log/wide/session" "github.com/b3log/wide/util" ) @@ -58,10 +59,16 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { } filePath := args["executable"].(string) - curDir := filepath.Dir(filePath) - cmd := exec.Command(filePath) - cmd.Dir = curDir + var cmd *exec.Cmd + if conf.Docker { + fileName := filepath.Base(filePath) + cmd = exec.Command("docker", "run", "--rm", "-v", filePath+":/"+fileName, "busybox", "timeout", "10", "/"+fileName) + } else { + cmd = exec.Command(filePath) + curDir := filepath.Dir(filePath) + cmd.Dir = curDir + } stdout, err := cmd.StdoutPipe() if nil != err {