🐳 仅限制 CPU

This commit is contained in:
Liang Ding 2019-05-17 18:27:39 +08:00
parent 43a3ffe2a0
commit 802178cbf3
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
2 changed files with 2 additions and 2 deletions

View File

@ -51,7 +51,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
var cmd *exec.Cmd var cmd *exec.Cmd
if conf.Docker { if conf.Docker {
fileName := filepath.Base(filePath) fileName := filepath.Base(filePath)
cmd = exec.Command("timeout", "5", "docker", "run", "--rm", "--cpus", "0.1", "--memory", "32m", "-v", filePath+":/"+fileName, conf.DockerImageGo, "/"+fileName) cmd = exec.Command("timeout", "5", "docker", "run", "--rm", "--cpus", "0.1", "-v", filePath+":/"+fileName, conf.DockerImageGo, "/"+fileName)
} else { } else {
cmd = exec.Command(filePath) cmd = exec.Command(filePath)
curDir := filepath.Dir(filePath) curDir := filepath.Dir(filePath)

View File

@ -52,7 +52,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
var cmd *exec.Cmd var cmd *exec.Cmd
if conf.Docker { if conf.Docker {
fileName := filepath.Base(filePath) fileName := filepath.Base(filePath)
cmd = exec.Command("timeout", "5", "docker", "run", "--rm", "--cpus", "0.1", "--memory", "32m", "-v", filePath+":/"+fileName, conf.DockerImageGo, "/"+fileName) cmd = exec.Command("timeout", "5", "docker", "run", "--rm", "--cpus", "0.1", "-v", filePath+":/"+fileName, conf.DockerImageGo, "/"+fileName)
} else { } else {
cmd = exec.Command(filePath) cmd = exec.Command(filePath)
curDir := filepath.Dir(filePath) curDir := filepath.Dir(filePath)