mirror of
https://github.com/status-im/fathom.git
synced 2025-03-01 03:20:27 +00:00
set WriteTimeout and ReadTimeout on http.Server
This commit is contained in:
parent
c71907033e
commit
defb36b001
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
@ -66,10 +67,13 @@ func server(c *cli.Context) error {
|
|||||||
if !c.Bool("lets-encrypt") {
|
if !c.Bool("lets-encrypt") {
|
||||||
// start listening
|
// start listening
|
||||||
log.Printf("Server is now listening on %s", addr)
|
log.Printf("Server is now listening on %s", addr)
|
||||||
err := http.ListenAndServe(addr, h)
|
server := &http.Server{
|
||||||
if err != nil {
|
Addr: addr,
|
||||||
log.Errorln(err)
|
Handler: h,
|
||||||
|
ReadTimeout: 10 * time.Second,
|
||||||
|
WriteTimeout: 10 * time.Second,
|
||||||
}
|
}
|
||||||
|
log.Fatal(server.ListenAndServe())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user