optimize output stderr 📜
This commit is contained in:
parent
0a5a88335d
commit
a2f50ae94e
|
@ -191,6 +191,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
buf := outputBuf{}
|
||||||
for {
|
for {
|
||||||
r, _, err := errReader.ReadRune()
|
r, _, err := errReader.ReadRune()
|
||||||
|
|
||||||
|
@ -199,19 +200,32 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := string(r)
|
oneRuneStr := string(r)
|
||||||
buf = strings.Replace(buf, "<", "<", -1)
|
oneRuneStr = strings.Replace(oneRuneStr, "<", "<", -1)
|
||||||
buf = strings.Replace(buf, ">", ">", -1)
|
oneRuneStr = strings.Replace(oneRuneStr, ">", ">", -1)
|
||||||
|
|
||||||
channelRet["cmd"] = "run"
|
buf.content += oneRuneStr
|
||||||
channelRet["output"] = "<span class='stderr'>" + buf + "</span>"
|
|
||||||
err = wsChannel.WriteJSON(&channelRet)
|
now := time.Now().UnixNano() / int64(time.Millisecond)
|
||||||
if nil != err {
|
|
||||||
logger.Error(err)
|
if 0 == buf.millisecond {
|
||||||
break
|
buf.millisecond = now
|
||||||
}
|
}
|
||||||
|
|
||||||
wsChannel.Refresh()
|
if now-outputTimeout >= buf.millisecond || len(buf.content) > outputBufMax || oneRuneStr == "\n" {
|
||||||
|
channelRet["cmd"] = "run"
|
||||||
|
channelRet["output"] = "<span class='stderr'>" + buf.content + "</span>"
|
||||||
|
|
||||||
|
buf = outputBuf{} // a new buffer
|
||||||
|
|
||||||
|
err = wsChannel.WriteJSON(&channelRet)
|
||||||
|
if nil != err {
|
||||||
|
logger.Error(err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
wsChannel.Refresh()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}(rand.Int())
|
}(rand.Int())
|
||||||
}
|
}
|
||||||
|
|
|
@ -439,6 +439,7 @@
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
overflow-x: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bottom-window-group .output pre {
|
.bottom-window-group .output pre {
|
||||||
|
|
Loading…
Reference in New Issue