Fix #169
This commit is contained in:
parent
58e54a1fa0
commit
50b2daa9f7
|
@ -105,9 +105,8 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
data["succ"] = false
|
||||
}
|
||||
|
||||
//outReader := bufio.NewReader(stdout)
|
||||
outReader := util.NewReader(stdout)
|
||||
errReader := bufio.NewReader(stderr)
|
||||
errReader := util.NewReader(stderr)
|
||||
|
||||
if err := cmd.Start(); nil != err {
|
||||
glog.Error(err)
|
||||
|
@ -162,7 +161,6 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
go func() {
|
||||
for {
|
||||
buf, err := outReader.ReadData()
|
||||
//buf, err := outReader.ReadString('\n')
|
||||
buf = strings.Replace(buf, "<", "<", -1)
|
||||
buf = strings.Replace(buf, ">", ">", -1)
|
||||
|
||||
|
@ -204,45 +202,43 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}()
|
||||
|
||||
for {
|
||||
buf, err := errReader.ReadString('\n')
|
||||
buf, err := errReader.ReadData()
|
||||
buf = strings.Replace(buf, "<", "<", -1)
|
||||
buf = strings.Replace(buf, ">", ">", -1)
|
||||
|
||||
if nil == session.OutputWS[sid] {
|
||||
break
|
||||
}
|
||||
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
if nil != err {
|
||||
// remove the exited process from user process set
|
||||
processes.remove(wSession, cmd.Process)
|
||||
|
||||
glog.V(5).Infof("Session [%s] 's running [id=%d, file=%s] has done [stderr err]", sid, runningId, filePath)
|
||||
|
||||
if nil != session.OutputWS[sid] {
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
channelRet["cmd"] = "run-done"
|
||||
channelRet["output"] = buf
|
||||
err := wsChannel.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
break
|
||||
}
|
||||
|
||||
wsChannel.Refresh()
|
||||
channelRet["cmd"] = "run-done"
|
||||
channelRet["output"] = "<span class='stderr'>" + buf + "</span>"
|
||||
err := wsChannel.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
break
|
||||
}
|
||||
|
||||
wsChannel.Refresh()
|
||||
|
||||
break
|
||||
} else {
|
||||
if nil != session.OutputWS[sid] {
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
channelRet["cmd"] = "run"
|
||||
channelRet["output"] = buf
|
||||
err := wsChannel.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
break
|
||||
}
|
||||
|
||||
wsChannel.Refresh()
|
||||
channelRet["cmd"] = "run"
|
||||
channelRet["output"] = "<span class='stderr'>" + buf + "</span>"
|
||||
err := wsChannel.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
break
|
||||
}
|
||||
|
||||
wsChannel.Refresh()
|
||||
}
|
||||
}
|
||||
}(rand.Int())
|
||||
|
@ -391,7 +387,8 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// build gutter lint
|
||||
|
||||
errOut := string(buf)
|
||||
channelRet["output"] = "<span class='build-error'>" + i18n.Get(locale, "build-error").(string) + "</span>\n" + errOut
|
||||
channelRet["output"] = "<span class='build-error'>" + i18n.Get(locale, "build-error").(string) + "</span>\n" +
|
||||
"<span class='stderr'>" + errOut + "</span>"
|
||||
|
||||
lines := strings.Split(errOut, "\n")
|
||||
|
||||
|
|
|
@ -322,6 +322,11 @@
|
|||
color: #9d0000;
|
||||
}
|
||||
|
||||
.bottom-window-group .output .stderr {
|
||||
color: gray;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.bottom-window-group table {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue