check a second time if there was a change
This commit is contained in:
parent
09b2073e1e
commit
aa20d59a0f
1 changed files with 19 additions and 9 deletions
|
@ -48,15 +48,7 @@ func main() {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
for _, d := range config.Domains {
|
for _, d := range config.Domains {
|
||||||
domain := dns.CheckDomain(d)
|
go checkDomain(0, d, repo, client)
|
||||||
retrievedDomain, _ := repo.GetValue(d)
|
|
||||||
if reflect.DeepEqual(domain, retrievedDomain) {
|
|
||||||
log.Debugf(" %v: did not change", d)
|
|
||||||
} else {
|
|
||||||
log.Infof("!%v: changed", d)
|
|
||||||
go sendWebhook(client, domain, retrievedDomain)
|
|
||||||
repo.SetValue(domain)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case <-tickerGC.C:
|
case <-tickerGC.C:
|
||||||
|
@ -81,6 +73,24 @@ func main() {
|
||||||
<-s
|
<-s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkDomain(counter int, d string, repo *repository.DomainRepository, client webhook.Client) {
|
||||||
|
domain := dns.CheckDomain(d)
|
||||||
|
retrievedDomain, _ := repo.GetValue(d)
|
||||||
|
if reflect.DeepEqual(domain, retrievedDomain) {
|
||||||
|
log.Debugf(" %v: did not change", d)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Infof("!%v: changed", d)
|
||||||
|
counter += 1
|
||||||
|
if counter >= 2 {
|
||||||
|
go sendWebhook(client, domain, retrievedDomain)
|
||||||
|
repo.SetValue(domain)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(1 * time.Minute)
|
||||||
|
checkDomain(counter, d, repo, client)
|
||||||
|
}
|
||||||
|
|
||||||
func sendWebhook(client webhook.Client, domain repository.Domain, oldDomain repository.Domain) {
|
func sendWebhook(client webhook.Client, domain repository.Domain, oldDomain repository.Domain) {
|
||||||
var status string
|
var status string
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue