mirror of
https://github.com/go-shiori/shiori.git
synced 2025-01-17 05:17:59 +08:00
Set server timeouts
Set server timeouts to avoid leaked descriptors on slow or disappearing clients or slow http attacks. Fixes #51
This commit is contained in:
parent
9d3c8eedf9
commit
12c118f4bc
1 changed files with 7 additions and 1 deletions
|
@ -74,7 +74,13 @@ var (
|
|||
port, _ := cmd.Flags().GetInt("port")
|
||||
url := fmt.Sprintf(":%d", port)
|
||||
logrus.Infoln("Serve shiori in", url)
|
||||
logrus.Fatalln(http.ListenAndServe(url, router))
|
||||
svr := &http.Server{
|
||||
Addr: url,
|
||||
Handler: router,
|
||||
ReadTimeout: 10 * time.Second,
|
||||
WriteTimeout: 20 * time.Second,
|
||||
}
|
||||
logrus.Fatalln(svr.ListenAndServe())
|
||||
},
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue