notsure
This commit is contained in:
parent
60248b5931
commit
ac5da98149
2
main.go
2
main.go
|
@ -44,8 +44,6 @@ func main() {
|
||||||
me.pollDelay = 3 * time.Second
|
me.pollDelay = 3 * time.Second
|
||||||
me.failcountmax = 20 // die every minute if zookeeper can't be found
|
me.failcountmax = 20 // die every minute if zookeeper can't be found
|
||||||
|
|
||||||
// me.machine.ConfigLoad()
|
|
||||||
|
|
||||||
me.forge = forgepb.InitPB()
|
me.forge = forgepb.InitPB()
|
||||||
me.machine = zoopb.InitMachine()
|
me.machine = zoopb.InitMachine()
|
||||||
|
|
||||||
|
|
34
watchdog.go
34
watchdog.go
|
@ -20,6 +20,21 @@ func NewWatchdog() {
|
||||||
me.dog = time.NewTicker(me.pollDelay)
|
me.dog = time.NewTicker(me.pollDelay)
|
||||||
defer me.dog.Stop()
|
defer me.dog.Stop()
|
||||||
done := make(chan bool)
|
done := make(chan bool)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
fmt.Println("Done!")
|
||||||
|
return
|
||||||
|
case _ = <-me.dog.C:
|
||||||
|
s := me.machine.UpdatePackages()
|
||||||
|
me.failcount += 1
|
||||||
|
sendMachine(s)
|
||||||
|
|
||||||
|
if me.failcount > 20 {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
// this example would exit/destroy the ticker in 10 seconds
|
// this example would exit/destroy the ticker in 10 seconds
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -27,23 +42,4 @@ func NewWatchdog() {
|
||||||
done <- true
|
done <- true
|
||||||
}()
|
}()
|
||||||
*/
|
*/
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
fmt.Println("Done!")
|
|
||||||
return
|
|
||||||
case _ = <-me.dog.C:
|
|
||||||
// log.Info("Watchdog() ticked", me.zookeeper, "Current time: ", t)
|
|
||||||
s := me.machine.UpdatePackages()
|
|
||||||
// pingStatus()
|
|
||||||
me.failcount += 1
|
|
||||||
sendMachine(s)
|
|
||||||
|
|
||||||
if me.failcount > 20 {
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
// h.pollHypervisor()
|
|
||||||
// h.Scan()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue