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,
|
|
|
|
syscall.SIGSTOP,
|
|
|
|
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
|
|
|
}
|