mirror of
https://github.com/pgsty/minio.git
synced 2026-07-20 20:50:22 +03:00
initialize forwarder after init() to avoid crashes (#11330)
DNSCache dialer is a global value initialized in init(), whereas `go` keeps `var =` before `init()` , also we don't need to keep proxy routers as global entities - register the forwarder as necessary to avoid crashes.
This commit is contained in:
@@ -41,6 +41,7 @@ import (
|
||||
"github.com/minio/minio/pkg/certs"
|
||||
"github.com/minio/minio/pkg/console"
|
||||
"github.com/minio/minio/pkg/env"
|
||||
"github.com/minio/minio/pkg/handlers"
|
||||
)
|
||||
|
||||
// serverDebugLog will enable debug printing
|
||||
@@ -51,10 +52,19 @@ func init() {
|
||||
logger.RegisterError(config.FmtError)
|
||||
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
globalDNSCache = xhttp.NewDNSCache(10*time.Second, 10*time.Second, logger.LogOnceIf)
|
||||
|
||||
initGlobalContext()
|
||||
|
||||
globalForwarder = handlers.NewForwarder(&handlers.Forwarder{
|
||||
PassHost: true,
|
||||
RoundTripper: newGatewayHTTPTransport(1 * time.Hour),
|
||||
Logger: func(err error) {
|
||||
logger.LogIf(GlobalContext, err)
|
||||
},
|
||||
})
|
||||
|
||||
globalReplicationState = newReplicationState()
|
||||
globalTransitionState = newTransitionState()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user