mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-07-02 21:52:51 +08:00
fix block channel.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
5b0ba436e2
commit
daaf2e2b25
@ -11,8 +11,6 @@ import (
|
|||||||
"github.com/appleboy/easyssh-proxy"
|
"github.com/appleboy/easyssh-proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
missingHostOrUser = "Error: missing server host or user"
|
missingHostOrUser = "Error: missing server host or user"
|
||||||
missingPasswordOrKey = "Error: can't connect without a private SSH key or password"
|
missingPasswordOrKey = "Error: can't connect without a private SSH key or password"
|
||||||
@ -59,6 +57,7 @@ func (p Plugin) Exec() error {
|
|||||||
return fmt.Errorf(setPasswordandKey)
|
return fmt.Errorf(setPasswordandKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
wg.Add(len(p.Config.Host))
|
wg.Add(len(p.Config.Host))
|
||||||
errChannel := make(chan error, 1)
|
errChannel := make(chan error, 1)
|
||||||
finished := make(chan bool, 1)
|
finished := make(chan bool, 1)
|
||||||
@ -88,7 +87,7 @@ func (p Plugin) Exec() error {
|
|||||||
stdoutChan, stderrChan, doneChan, errChan, err := ssh.Stream(strings.Join(p.Config.Script, "\n"), p.Config.CommandTimeout)
|
stdoutChan, stderrChan, doneChan, errChan, err := ssh.Stream(strings.Join(p.Config.Script, "\n"), p.Config.CommandTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errChannel <- err
|
errChannel <- err
|
||||||
}
|
} else {
|
||||||
// read from the output channel until the done signal is passed
|
// read from the output channel until the done signal is passed
|
||||||
stillGoing := true
|
stillGoing := true
|
||||||
isTimeout := true
|
isTimeout := true
|
||||||
@ -113,6 +112,8 @@ func (p Plugin) Exec() error {
|
|||||||
if !isTimeout {
|
if !isTimeout {
|
||||||
errChannel <- fmt.Errorf(commandTimeOut)
|
errChannel <- fmt.Errorf(commandTimeOut)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(host)
|
}(host)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user