This commit is contained in:
parent
db36400f57
commit
2f6b9f0e2f
|
@ -495,7 +495,6 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
glog.V(3).Infof("Session [%s] is running [go install] [id=%d, dir=%s]", sid, runningId, curDir)
|
||||
|
||||
// 一次性读取
|
||||
// 一次性读取
|
||||
buf, _ := ioutil.ReadAll(reader)
|
||||
|
||||
|
@ -654,51 +653,18 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
channelRet := map[string]interface{}{}
|
||||
channelRet["cmd"] = "go get"
|
||||
|
||||
for {
|
||||
buf, err := reader.ReadBytes('\n')
|
||||
// 一次性读取
|
||||
buf, _ := ioutil.ReadAll(reader)
|
||||
|
||||
channelRet["output"] = string(buf)
|
||||
|
||||
if nil != err {
|
||||
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done (with error: %v)", sid, runningId, err)
|
||||
if 0 != len(buf) {
|
||||
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done (with error)", sid, runningId)
|
||||
|
||||
channelRet["output"] = "<span class='get-failed'>" + i18n.Get(r, "get-failed").(string) + "</span>\n" + string(buf)
|
||||
|
||||
if nil != session.OutputWS[sid] {
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
err := wsChannel.Conn.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
break
|
||||
}
|
||||
|
||||
// 更新通道最近使用时间
|
||||
wsChannel.Time = time.Now()
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
if 0 == len(buf) {
|
||||
} else {
|
||||
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done", sid, runningId)
|
||||
|
||||
channelRet["output"] = "<span class='get-succ'>" + i18n.Get(r, "get-succ").(string) + "</span>\n"
|
||||
|
||||
if nil != session.OutputWS[sid] {
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
err := wsChannel.Conn.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
break
|
||||
}
|
||||
|
||||
// 更新通道最近使用时间
|
||||
wsChannel.Time = time.Now()
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
if nil != session.OutputWS[sid] {
|
||||
|
@ -707,13 +673,11 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
err := wsChannel.Conn.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
break
|
||||
}
|
||||
|
||||
// 更新通道最近使用时间
|
||||
wsChannel.Time = time.Now()
|
||||
}
|
||||
}
|
||||
}(rand.Int())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue