Skip to content

Commit

Permalink
Merge pull request #3 from gerrowadat/server
Browse files Browse the repository at this point in the history
Rudimentary doing of the thing over and over.
  • Loading branch information
gerrowadat authored Nov 7, 2023
2 parents a8c00a9 + 8eb3469 commit b3604a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

# Go workspace file
go.work
clouddns-sync
key.json
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"log"
"os"
"time"

google_oauth "golang.org/x/oauth2/google"
"google.golang.org/api/dns/v1"
Expand Down Expand Up @@ -32,6 +33,7 @@ func main() {

var nomadServerURI = flag.String("nomad-server-uri", "http://localhost:4646", "URI for a nomad server to talk to.")
var nomadTokenFile = flag.String("nomad-token-file", "", "file to read ou rnomad token from")
var nomadSyncInterval = flag.Int("nomad-sync-interval-secs", 300, "seconds between nomad updates. set to -1 to sync once only.")

flag.Parse()

Expand Down Expand Up @@ -109,6 +111,14 @@ func main() {
}

syncNomad(dns_spec, nomadSpec, dryRun, pruneMissing)

if *nomadSyncInterval >= 0 {
for {
log.Printf("Waiting %d seconds.", *nomadSyncInterval)
time.Sleep(time.Duration(*nomadSyncInterval) * time.Second)
syncNomad(dns_spec, nomadSpec, dryRun, pruneMissing)
}
}
default:
log.Fatal("Unknown verb: ", verb)
}
Expand Down

0 comments on commit b3604a2

Please sign in to comment.