// sigterm package main import ( "fmt" "log" "os" "os/signal" "syscall" "time" ) func kill() { log.Printf("KILL %d\n", status) fmt.Printf("KILL %d\n", status) wg.Done() counter <- Counterchan{ tipo: "wg", val: -1, } done <- true } func exit() { log.Printf("EXIT %d\n", status) fmt.Printf("EXIT %d\n", status) loop = false time.AfterFunc(time.Second*20, kill) } func setTerm() { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) signal.Notify(c, syscall.SIGTERM) go func() { <-c exit() }() }