🎨 Docker 环境输出延时问题
This commit is contained in:
parent
e4f0e410b8
commit
aa65a8db04
|
@ -68,7 +68,7 @@ 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", "--cpus", "0.05", "--name", rid, "-v", filePath+":/"+fileName, conf.DockerImageGo, "/"+fileName)
|
cmd = exec.Command("docker", "run", "-t", "--rm", "--cpus", "0.05", "--name", rid, "-v", filePath+":/"+fileName, conf.DockerImageGo, "/"+fileName)
|
||||||
} else {
|
} else {
|
||||||
cmd = exec.Command(filePath)
|
cmd = exec.Command(filePath)
|
||||||
curDir := filepath.Dir(filePath)
|
curDir := filepath.Dir(filePath)
|
||||||
|
@ -123,12 +123,10 @@ func RunHandler(w http.ResponseWriter, r *http.Request, channel map[string]*util
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer gulu.Panic.Recover(nil)
|
defer gulu.Panic.Recover(nil)
|
||||||
|
|
||||||
logger.Debugf("User [%s, %s] is running [id=%s, file=%s]", wSession.UserId, sid, rid, filePath)
|
logger.Debugf("User [%s, %s] is running [id=%s, file=%s]", wSession.UserId, sid, rid, filePath)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer gulu.Panic.Recover(nil)
|
defer gulu.Panic.Recover(nil)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
r, _, err := outReader.ReadRune()
|
r, _, err := outReader.ReadRune()
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
Loading…
Reference in New Issue