go get 提示
This commit is contained in:
parent
a35f09cc02
commit
959ec33b9e
|
@ -81,11 +81,14 @@
|
|||
"focus_output": "焦点切换到输出窗口",
|
||||
"focus_search": "焦点切换到搜索窗口",
|
||||
"focus_notification": "焦点切换到通知窗口",
|
||||
"start-build": "开始构建",
|
||||
"build-succ": "构建成功",
|
||||
"build-failed": "构建失败",
|
||||
"start-install": "开始 go install",
|
||||
"install-succ": "go install 成功",
|
||||
"install-failed": "go install 失败",
|
||||
"start-build": "开始 [go build]",
|
||||
"build-succ": "[go build] 成功",
|
||||
"build-failed": "[go build] 失败",
|
||||
"start-install": "开始 [go install]",
|
||||
"install-succ": "[go install] 成功",
|
||||
"install-failed": "[go install] 失败",
|
||||
"start-get": "开始 [go get]",
|
||||
"get-succ": "[go get] 成功",
|
||||
"get-failed": "[go get] 失败",
|
||||
"colon": ":"
|
||||
}
|
|
@ -463,7 +463,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
channelRet := map[string]interface{}{}
|
||||
|
||||
if nil != session.OutputWS[sid] {
|
||||
// 在前端 output 中显示“开始构建”
|
||||
// 在前端 output 中显示“开始 go install”
|
||||
|
||||
channelRet["output"] = i18n.Get(r, "start-install").(string) + "\n"
|
||||
channelRet["cmd"] = "start-install"
|
||||
|
@ -613,29 +613,58 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
reader := io.MultiReader(stdout, stderr)
|
||||
|
||||
cmd.Start()
|
||||
if !data["succ"].(bool) {
|
||||
return
|
||||
}
|
||||
|
||||
channelRet := map[string]interface{}{}
|
||||
|
||||
if nil != session.OutputWS[sid] {
|
||||
// 在前端 output 中显示“开始 go get
|
||||
|
||||
channelRet["output"] = i18n.Get(r, "start-get").(string) + "\n"
|
||||
channelRet["cmd"] = "start-get"
|
||||
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
err := wsChannel.Conn.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新通道最近使用时间
|
||||
wsChannel.Time = time.Now()
|
||||
}
|
||||
|
||||
reader := io.MultiReader(stdout, stderr)
|
||||
|
||||
if err := cmd.Start(); nil != err {
|
||||
glog.Error(err)
|
||||
data["succ"] = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
go func(runningId int) {
|
||||
defer util.Recover()
|
||||
defer cmd.Wait()
|
||||
|
||||
glog.V(3).Infof("Session [%s] is running [go get] [runningId=%d]", sid, runningId)
|
||||
|
||||
channelRet := map[string]interface{}{}
|
||||
channelRet["cmd"] = "go get"
|
||||
|
||||
for {
|
||||
buf := make([]byte, 1024)
|
||||
count, err := reader.Read(buf)
|
||||
|
||||
if nil != err || 0 == count {
|
||||
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done", sid, runningId)
|
||||
|
||||
break
|
||||
} else {
|
||||
channelRet["output"] = string(buf[:count])
|
||||
channelRet["cmd"] = "go get"
|
||||
|
||||
if nil != err {
|
||||
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done (with error)", sid, runningId)
|
||||
|
||||
channelRet["output"] = i18n.Get(r, "get-failed").(string) + "\n" + string(buf[:count])
|
||||
|
||||
if nil != session.OutputWS[sid] {
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
@ -649,6 +678,42 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// 更新通道最近使用时间
|
||||
wsChannel.Time = time.Now()
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
if 0 == count {
|
||||
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done", sid, runningId)
|
||||
|
||||
channelRet["output"] = i18n.Get(r, "get-succ").(string) + "\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] {
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
err := wsChannel.Conn.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
break
|
||||
}
|
||||
|
||||
// 更新通道最近使用时间
|
||||
wsChannel.Time = time.Now()
|
||||
}
|
||||
}
|
||||
}(rand.Int())
|
||||
|
|
|
@ -344,13 +344,11 @@ var wide = {
|
|||
break;
|
||||
case 'start-build':
|
||||
case 'start-install':
|
||||
case 'start-get':
|
||||
wide.fillOutput(data.output);
|
||||
|
||||
break;
|
||||
case 'go install':
|
||||
wide.fillOutput($('.bottom-window-group .output').text() + data.output);
|
||||
|
||||
break;
|
||||
case 'go get':
|
||||
wide.fillOutput($('.bottom-window-group .output').text() + data.output);
|
||||
|
||||
|
|
Loading…
Reference in New Issue