Commit 606bc920 authored by Adrian Sutton's avatar Adrian Sutton

op-node: Set timeouts on http servers

parent cdb0195e
...@@ -19,7 +19,7 @@ import ( ...@@ -19,7 +19,7 @@ import (
"time" "time"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/server" ophttp "github.com/ethereum-optimism/optimism/op-node/http"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
) )
...@@ -162,7 +162,7 @@ func runServer() { ...@@ -162,7 +162,7 @@ func runServer() {
mux.HandleFunc("/logs", makeGzipHandler(logsHandler)) mux.HandleFunc("/logs", makeGzipHandler(logsHandler))
log.Info("running webserver...") log.Info("running webserver...")
httpServer := server.NewHttpServer(mux) httpServer := ophttp.NewHttpServer(mux)
if err := httpServer.Serve(l); err != nil && !errors.Is(err, http.ErrServerClosed) { if err := httpServer.Serve(l); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Crit("http server failed", "message", err) log.Crit("http server failed", "message", err)
} }
......
package server package http
import ( import (
"net/http" "net/http"
......
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/ethereum-optimism/optimism/op-node/server" ophttp "github.com/ethereum-optimism/optimism/op-node/http"
"github.com/ethereum-optimism/optimism/op-service/metrics" "github.com/ethereum-optimism/optimism/op-service/metrics"
pb "github.com/libp2p/go-libp2p-pubsub/pb" pb "github.com/libp2p/go-libp2p-pubsub/pb"
...@@ -528,7 +528,7 @@ func (m *Metrics) RecordSequencerSealingTime(duration time.Duration) { ...@@ -528,7 +528,7 @@ func (m *Metrics) RecordSequencerSealingTime(duration time.Duration) {
// The server will be closed when the passed-in context is cancelled. // The server will be closed when the passed-in context is cancelled.
func (m *Metrics) Serve(ctx context.Context, hostname string, port int) error { func (m *Metrics) Serve(ctx context.Context, hostname string, port int) error {
addr := net.JoinHostPort(hostname, strconv.Itoa(port)) addr := net.JoinHostPort(hostname, strconv.Itoa(port))
server := server.NewHttpServer(promhttp.InstrumentMetricHandler( server := ophttp.NewHttpServer(promhttp.InstrumentMetricHandler(
m.registry, promhttp.HandlerFor(m.registry, promhttp.HandlerOpts{}), m.registry, promhttp.HandlerFor(m.registry, promhttp.HandlerOpts{}),
)) ))
server.Addr = addr server.Addr = addr
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"net/http" "net/http"
"strconv" "strconv"
"github.com/ethereum-optimism/optimism/op-node/server" ophttp "github.com/ethereum-optimism/optimism/op-node/http"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
...@@ -88,7 +88,7 @@ func (s *rpcServer) Start() error { ...@@ -88,7 +88,7 @@ func (s *rpcServer) Start() error {
} }
s.listenAddr = listener.Addr() s.listenAddr = listener.Addr()
s.httpServer = server.NewHttpServer(mux) s.httpServer = ophttp.NewHttpServer(mux)
go func() { go func() {
if err := s.httpServer.Serve(listener); err != nil && !errors.Is(err, http.ErrServerClosed) { // todo improve error handling if err := s.httpServer.Serve(listener); err != nil && !errors.Is(err, http.ErrServerClosed) { // todo improve error handling
s.log.Error("http server failed", "err", err) s.log.Error("http server failed", "err", err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment