mirror of
https://github.com/ouqiang/gocron.git
synced 2024-04-21 12:31:58 +00:00
修复goroutine未正常退出
This commit is contained in:
+1
-2
@@ -27,7 +27,6 @@ func Exec(sshConfig SSHConfig, cmd string) (output string, err error) {
|
||||
var timeoutChan chan bool = make(chan bool)
|
||||
go execCommand(sshConfig, cmd, resultChan)
|
||||
go triggerTimeout(timeoutChan, sshConfig.ExecTimeout)
|
||||
|
||||
select {
|
||||
case result := <- resultChan:
|
||||
output = result.Output
|
||||
@@ -81,5 +80,5 @@ func triggerTimeout(ch chan bool, timeout int){
|
||||
timeout = 86400
|
||||
}
|
||||
time.Sleep(time.Duration(timeout) * time.Second)
|
||||
ch <- true
|
||||
close(ch)
|
||||
}
|
||||
Reference in New Issue
Block a user