Use flags for config file and daemon mode
This commit is contained in:
parent
9c571f4c23
commit
338c337736
2 changed files with 9 additions and 9 deletions
|
@ -10,7 +10,7 @@ import (
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
func updateDomain(a api.API, currentIP, domain string) error {
|
func updateDomain(a api.API, currentIP, domain string) error {
|
||||||
records, err := api.GetRecords(domain)
|
records, err := a.GetRecords(domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
16
main.go
16
main.go
|
@ -1,17 +1,19 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mfycheng/name-dyndns/api"
|
"github.com/mfycheng/name-dyndns/api"
|
||||||
|
"github.com/mfycheng/name-dyndns/dyndns"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
defaultConfigPath = "./config.json"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
configs, err := api.LoadConfigs(defaultConfigPath)
|
configPath := flag.String("config", "./config.json", "Specify the configuration file")
|
||||||
|
daemon := flag.Bool("daemon", false, "operate in daemon mode")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
configs, err := api.LoadConfigs(*configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error loading config:", err)
|
fmt.Println("Error loading config:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -19,7 +21,5 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Successfully loaded %d configs\n", len(configs))
|
fmt.Printf("Successfully loaded %d configs\n", len(configs))
|
||||||
for _, config := range configs {
|
dyndns.Run(configs, *daemon)
|
||||||
fmt.Println("Processing config", config)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue