easyssh-proxy
easyssh-proxy copied to clipboard
[WIP]: add continueOnError param
Fix https://github.com/appleboy/drone-ssh/issues/66
@appleboy Can you tell me why the test failed? http://drone.wu-boy.com/appleboy/easyssh-proxy/74/3
By adding some debug lines, I found out that:
continueOnError is false by default, session.Run calls session.Wait:
- https://github.com/quantonganh/easyssh-proxy/blob/master/easyssh.go#L189
func (s *Session) Wait() error {
if !s.started {
return errors.New("ssh: session not started")
}
waitErr := <-s.exitStatus
After that: https://github.com/quantonganh/easyssh-proxy/blob/master/easyssh.go#L226
select {
case <-res:
errChan <- session.Wait()
doneChan <- true
and looks like this is where it is hanging.
I'm not sure what is the root cause. Could you please help me take a look?
When you changed session.Start to session.Run, after command is executed there are 2 places where session.Wait is called:
- https://github.com/appleboy/easyssh-proxy/blob/2a8dbafca512224bde2b1992c66745aec562d3ac/easyssh.go#L219
- https://github.com/golang/crypto/blob/12892e8c234f4fe6f6803f052061de9057903bb2/ssh/session.go#L314
session.Wait will receive the message in channel s.exitStatus (https://github.com/golang/crypto/blob/12892e8c234f4fe6f6803f052061de9057903bb2/ssh/session.go#L403). So when it is called 2 times, only one get the message, and the other one will hang forever.
So, I don't think your change from session.Start to session.Run is correct, that causes the hang.