🎨 Docker 容器限制 CPU 和内存
This commit is contained in:
parent
2e53a02446
commit
de0110eadf
|
@ -68,8 +68,9 @@ func RunHandler(w http.ResponseWriter, r *http.Request, channel map[string]*util
|
||||||
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("docker", "run", "--rm", "--name", rid, "-v", filePath+":/"+fileName, conf.DockerImageGo,
|
cmd = exec.Command("docker", "run", "--rm", "--name", rid, "-v", filePath+":/"+fileName,
|
||||||
"--memory", "64M", "--cpus", "0.1", "/"+fileName)
|
"--memory", "64M", "--cpus", "0.1",
|
||||||
|
conf.DockerImageGo, "/"+fileName)
|
||||||
} else {
|
} else {
|
||||||
cmd = exec.Command(filePath)
|
cmd = exec.Command(filePath)
|
||||||
curDir := filepath.Dir(filePath)
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
Loading…
Reference in New Issue