Add more timeouts

This commit is contained in:
Geoff Stuart 2022-11-25 16:24:09 -05:00
parent b55e121642
commit d2b7c3889b
5 changed files with 10 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import (
"net"
"net/http"
"os"
"time"
"github.com/gbrlsnchs/jwt/v3"
"github.com/gorilla/mux"
@ -240,7 +241,8 @@ var runCmd = &cli.Command{
}
srv := &http.Server{
Handler: handler,
Handler: handler,
ReadHeaderTimeout: 3 * time.Second,
BaseContext: func(listener net.Listener) context.Context {
ctx, _ := tag.New(context.Background(), tag.Upsert(metrics.APIInterface, "lotus-wallet"))
return ctx

View File

@ -563,7 +563,8 @@ var runCmd = &cli.Command{
log.Info("Setting up control endpoint at " + address)
srv := &http.Server{
Handler: sealworker.WorkerHandler(nodeApi.AuthVerify, remoteHandler, workerApi, true),
Handler: sealworker.WorkerHandler(nodeApi.AuthVerify, remoteHandler, workerApi, true),
ReadHeaderTimeout: 3 * time.Second,
BaseContext: func(listener net.Listener) context.Context {
ctx, _ := tag.New(context.Background(), tag.Upsert(metrics.APIInterface, "lotus-worker"))
return ctx

View File

@ -9,6 +9,7 @@ import (
_ "net/http/pprof"
"runtime"
"strconv"
"time"
"github.com/google/uuid"
"github.com/gorilla/mux"
@ -51,7 +52,8 @@ func ServeRPC(h http.Handler, id string, addr multiaddr.Multiaddr) (StopFunc, er
// Instantiate the server and start listening.
srv := &http.Server{
Handler: h,
Handler: h,
ReadHeaderTimeout: 3 * time.Second,
BaseContext: func(listener net.Listener) context.Context {
ctx, _ := tag.New(context.Background(), tag.Upsert(metrics.APIInterface, id))
return ctx

View File

@ -182,7 +182,7 @@ func startFullNodeAPIServer(t *TestEnvironment, repo repo.Repo, napi api.FullNod
Next: mux.ServeHTTP,
}
srv := &http.Server{Handler: ah}
srv := &http.Server{Handler: ah, ReadHeaderTimeout: 3 * time.Second}
endpoint, err := repo.APIEndpoint()
if err != nil {

View File

@ -638,7 +638,7 @@ func startStorageMinerAPIServer(t *TestEnvironment, repo repo.Repo, minerApi api
return nil, fmt.Errorf("no API endpoint in repo: %w", err)
}
srv := &http.Server{Handler: ah}
srv := &http.Server{Handler: ah, ReadHeaderTimeout: 3 * time.Second}
listenAddr, err := startServer(endpoint, srv)
if err != nil {