Add timeouts for the explorer HTTP service

pull/3060/head
Sebastian Johnsson 5 years ago committed by Leo Chen
parent 1a4b1985b8
commit 1a6816c02b
  1. 8
      api/service/explorer/service.go

@ -102,7 +102,13 @@ func (s *Service) Run() *http.Server {
// Do serving now.
utils.Logger().Info().Str("port", GetExplorerPort(s.Port)).Msg("Listening")
server := &http.Server{Addr: addr, Handler: s.router}
server := &http.Server{
Addr: addr,
Handler: s.router,
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
}
go func() {
if err := server.ListenAndServe(); err != nil {
utils.Logger().Warn().Err(err).Msg("server.ListenAndServe()")

Loading…
Cancel
Save