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