From f2af6ba15466f7ac39f2c12ea29fab5b0c5415c4 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 6 Jul 2024 16:13:08 +0530 Subject: usage/Init: init --- cmd/redq/main.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'cmd') diff --git a/cmd/redq/main.go b/cmd/redq/main.go index df275d6..abac395 100644 --- a/cmd/redq/main.go +++ b/cmd/redq/main.go @@ -14,10 +14,7 @@ import ( ) func main() { - u := &usage.Usage { - Data : make(usage.UsageMap), - } - + var u usage.Usage iface, err := net.InterfaceByName("wlan0") if err != nil { @@ -32,14 +29,15 @@ func main() { defer conn.Close(ctx) queries := db.New(conn) + err = u.Init(iface) + if err != nil { + os.Exit(0) + } sigs := make(chan os.Signal, 1) signal.Notify(sigs, os.Interrupt, os.Kill, syscall.SIGTERM) go func () { <- sigs - err := u.UpdateDb(queries, ctx, false) - if err != nil { - log.Printf("updating Database: %s", err) - } + u.CleanUp(queries, ctx) os.Exit(0) }() -- cgit v1.2.3