diff --git a/main.go b/main.go index 65c05da..000dcaa 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ package main import ( + "context" "flag" "fmt" "net/http" @@ -30,6 +31,9 @@ func main() { flag.Parse() flag.Lookup("logtostderr").Value.Set("true") + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if *configPath == "" { glog.Fatal("Config file is necessary") } @@ -75,5 +79,5 @@ func main() { }() glog.Infof("Starting dhcplb in v%d mode", *version) - glog.Fatal(server.ListenAndServe()) + glog.Fatal(server.ListenAndServe(ctx)) }