probe/cmd/main.go

49 lines
798 B
Go
Raw Normal View History

2018-08-30 03:56:14 +00:00
//sudo setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
2018-08-03 06:57:19 +00:00
package main
2018-08-23 09:21:48 +00:00
import (
"context"
"log"
"os"
"os/signal"
"syscall"
"time"
2018-08-23 09:31:35 +00:00
olog "git.loafle.net/overflow/log-go"
2018-08-23 09:21:48 +00:00
"git.loafle.net/overflow_scanner/probe/server"
)
func init() {
}
2018-08-03 06:57:19 +00:00
func main() {
2018-08-23 09:31:35 +00:00
olog.InitializeLogger("")
defer olog.Logger().Sync()
2018-08-23 09:21:48 +00:00
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,
2018-09-13 03:11:37 +00:00
// syscall.SIGSTOP,
2018-08-23 09:21:48 +00:00
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT)
2018-08-03 06:57:19 +00:00
2018-08-23 09:21:48 +00:00
<-interrupt
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := s.Shutdown(ctx); err != nil {
log.Printf("error: %v", err)
}
2018-08-03 06:57:19 +00:00
}