This commit is contained in:
Liang Ding 2019-05-16 10:53:22 +08:00
parent 88f16e1057
commit 1a4feddf34
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
1 changed files with 10 additions and 3 deletions

View File

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