This commit is contained in:
Liang Ding 2015-03-20 16:37:03 +08:00
parent c13108a7c0
commit 8c1a705a6a
2 changed files with 16 additions and 14 deletions

View File

@ -145,17 +145,11 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
r, _, err := outReader.ReadRune() r, _, err := outReader.ReadRune()
oneRuneStr := string(r)
oneRuneStr = strings.Replace(oneRuneStr, "<", "&lt;", -1)
oneRuneStr = strings.Replace(oneRuneStr, ">", "&gt;", -1)
buf.content += oneRuneStr
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)
logger.Tracef("User [%s, %s] 's running [id=%d, file=%s] has done [stdout %v], ", wSession.Username, sid, runningId, filePath, err) logger.Debugf("User [%s, %s] 's running [id=%d, file=%s] has done [stdout %v], ", wSession.Username, sid, runningId, filePath, err)
channelRet["cmd"] = "run-done" channelRet["cmd"] = "run-done"
channelRet["output"] = buf.content channelRet["output"] = buf.content
@ -170,6 +164,12 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
break break
} }
oneRuneStr := string(r)
oneRuneStr = strings.Replace(oneRuneStr, "<", "&lt;", -1)
oneRuneStr = strings.Replace(oneRuneStr, ">", "&gt;", -1)
buf.content += oneRuneStr
now := time.Now().UnixNano() / int64(time.Millisecond) now := time.Now().UnixNano() / int64(time.Millisecond)
if 0 == buf.millisecond { if 0 == buf.millisecond {

View File

@ -115,6 +115,8 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
defer util.Recover() defer util.Recover()
defer cmd.Wait() defer cmd.Wait()
logger.Debugf("User [%s, %s] is running [id=%d, file=%s]", wSession.Username, sid, runningId, filePath)
// push once for front-end to get the 'run' state and pid // push once for front-end to get the 'run' state and pid
if nil != wsChannel { if nil != wsChannel {
channelRet["cmd"] = "run" channelRet["cmd"] = "run"
@ -141,17 +143,11 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
r, _, err := outReader.ReadRune() r, _, err := outReader.ReadRune()
oneRuneStr := string(r)
oneRuneStr = strings.Replace(oneRuneStr, "<", "&lt;", -1)
oneRuneStr = strings.Replace(oneRuneStr, ">", "&gt;", -1)
buf.content += oneRuneStr
if nil != err { if nil != err {
// remove the exited process from user process set // remove the exited process from user process set
output.Processes.Remove(wSession, cmd.Process) output.Processes.Remove(wSession, cmd.Process)
logger.Tracef("User [%s, %s] 's running [id=%d, file=%s] has done [stdout %v], ", wSession.Username, sid, runningId, filePath, err) logger.Debugf("User [%s, %s] 's running [id=%d, file=%s] has done [stdout %v], ", wSession.Username, sid, runningId, filePath, err)
channelRet["cmd"] = "run-done" channelRet["cmd"] = "run-done"
channelRet["output"] = buf.content channelRet["output"] = buf.content
@ -166,6 +162,12 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
break break
} }
oneRuneStr := string(r)
oneRuneStr = strings.Replace(oneRuneStr, "<", "&lt;", -1)
oneRuneStr = strings.Replace(oneRuneStr, ">", "&gt;", -1)
buf.content += oneRuneStr
now := time.Now().UnixNano() / int64(time.Millisecond) now := time.Now().UnixNano() / int64(time.Millisecond)
if 0 == buf.millisecond { if 0 == buf.millisecond {