More pretty logging and doc
This commit is contained in:
parent
fc2c0e4b81
commit
bb8b5534d2
3
main.go
3
main.go
|
@ -88,7 +88,8 @@ func init() {
|
||||||
session.FixedTimeReport()
|
session.FixedTimeReport()
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug("cross-compilation ", util.Go.GetCrossPlatforms())
|
logger.Debug("host ["+runtime.Version()+", "+runtime.GOOS+"_"+runtime.GOARCH+
|
||||||
|
"], cross-compilation ", util.Go.GetCrossPlatforms())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main.
|
// Main.
|
||||||
|
|
|
@ -32,7 +32,7 @@ var Processes = procs{}
|
||||||
// Exclusive lock.
|
// Exclusive lock.
|
||||||
var mutex sync.Mutex
|
var mutex sync.Mutex
|
||||||
|
|
||||||
// add adds the specified process to the user process set.
|
// Add adds the specified process to the user process set.
|
||||||
func (procs *procs) Add(wSession *session.WideSession, proc *os.Process) {
|
func (procs *procs) Add(wSession *session.WideSession, proc *os.Process) {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
|
@ -49,7 +49,7 @@ func (procs *procs) Add(wSession *session.WideSession, proc *os.Process) {
|
||||||
logger.Tracef("Session [%s] has [%d] processes", sid, len((*procs)[sid]))
|
logger.Tracef("Session [%s] has [%d] processes", sid, len((*procs)[sid]))
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove removes the specified process from the user process set.
|
// Remove removes the specified process from the user process set.
|
||||||
func (procs *procs) Remove(wSession *session.WideSession, proc *os.Process) {
|
func (procs *procs) Remove(wSession *session.WideSession, proc *os.Process) {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
|
@ -74,7 +74,7 @@ func (procs *procs) Remove(wSession *session.WideSession, proc *os.Process) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// kill kills a process specified by the given pid.
|
// Kill kills a process specified by the given pid.
|
||||||
func (procs *procs) Kill(wSession *session.WideSession, pid int) {
|
func (procs *procs) Kill(wSession *session.WideSession, pid int) {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
|
|
|
@ -149,7 +149,8 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// remove the exited process from user's process set
|
// remove the exited process from user's process set
|
||||||
Processes.Remove(wSession, cmd.Process)
|
Processes.Remove(wSession, cmd.Process)
|
||||||
|
|
||||||
logger.Debugf("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
|
||||||
|
|
Loading…
Reference in New Issue