//sudo setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump package main import ( "context" "log" "os" "os/signal" "syscall" "time" olog "git.loafle.net/overflow/log-go" "git.loafle.net/overflow_scanner/probe/server" ) func init() { } func main() { olog.InitializeLogger("") defer olog.Logger().Sync() s := server.New() go func() { err := s.ListenAndServe() if nil != err { log.Printf("err: %v", err) } }() interrupt := make(chan os.Signal, 1) signal.Notify(interrupt, syscall.SIGKILL, syscall.SIGSTOP, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) <-interrupt ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() if err := s.Shutdown(ctx); err != nil { log.Printf("error: %v", err) } }