change workdir to config dir

This commit is contained in:
Niklas 2021-01-08 19:12:58 +01:00
parent fe7c207065
commit c0d5ef7e22

View File

@ -7,6 +7,7 @@ import (
"net" "net"
"os" "os"
"os/signal" "os/signal"
"path/filepath"
"strings" "strings"
"syscall" "syscall"
@ -383,6 +384,11 @@ func main() {
configPath := flag.String("c", "/etc/cool-dns/config.yaml", "path to the config file") configPath := flag.String("c", "/etc/cool-dns/config.yaml", "path to the config file")
flag.Parse() flag.Parse()
err := os.Chdir(filepath.Dir(*configPath))
if err != nil {
log.Fatalf("Failed to goto config dir: %s", err.Error())
}
config, err := loadConfig(*configPath) config, err := loadConfig(*configPath)
if err != nil { if err != nil {
log.Fatalf("Failed to load config: %s\n", err.Error()) log.Fatalf("Failed to load config: %s\n", err.Error())