Merge pull request #52 from peteretelej/fix/timeouts

Set server timeouts
This commit is contained in:
Radhi 2018-03-07 08:10:06 +07:00 committed by GitHub
commit d0fc6a5525
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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())
},
}
)