const MaxConns = 128
-var GracefulTime = 10 * time.Second
+var (
+ GracefulTime = 10 * time.Second
+ RWTimeout = 30 * time.Second
+)
func main() {
bind := flag.String("bind", "[::]:80", "Address to bind and listen on")
shutdown := make(chan os.Signal)
signal.Notify(shutdown, syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP)
exitErr := make(chan error)
- l, err := net.Listen("tcp", *bind)
+ l, err := godlighty.DeadlinedListen("tcp", *bind, RWTimeout, RWTimeout)
if err != nil {
log.Fatalln(err)
}
}
}()
- srv := http.Server{Handler: godlighty.MainHandler}
+ srv := http.Server{
+ Handler: godlighty.MainHandler,
+ ReadHeaderTimeout: RWTimeout,
+ IdleTimeout: time.Minute,
+ }
go func() {
<-shutdown
log.Println("shutting down")