Set timeout and re-dial on any failures.
This commit is contained in:
parent
a61e9c7e1c
commit
5171c33d3c
@ -151,16 +151,23 @@ func main() {
|
||||
Auth: ams,
|
||||
// TODO(wathiede); use FixedHostKey?
|
||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||
}
|
||||
c, err := ssh.Dial("tcp", *host, config)
|
||||
if err != nil {
|
||||
glog.Exitf("Error dialing %q: %v", *host, err)
|
||||
Timeout: 5 * time.Second,
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
var c *ssh.Client
|
||||
if c == nil {
|
||||
var err error
|
||||
c, err = ssh.Dial("tcp", *host, config)
|
||||
if err != nil {
|
||||
glog.Errorf("Error dialing %q: %v", *host, err)
|
||||
}
|
||||
}
|
||||
if err := updateMetrics(c); err != nil {
|
||||
glog.Errorf("Failed to update metrics: %v", err)
|
||||
c.Close()
|
||||
c = nil
|
||||
}
|
||||
time.Sleep(*refreshInterval)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user