diff --git a/kong/core/handler.lua b/kong/core/handler.lua index f23a5221889..b7a56314b0f 100644 --- a/kong/core/handler.lua +++ b/kong/core/handler.lua @@ -31,6 +31,7 @@ local unpack = unpack local router, router_err, router_version local server_header = _KONG._NAME.."/".._KONG._VERSION +local balancer_initialized = false local function get_now() @@ -85,12 +86,6 @@ return { local cluster_events = singletons.cluster_events - -- initialize balancers - - - balancer.init() - - -- events dispatcher @@ -320,6 +315,14 @@ return { }, access = { before = function(ctx) + + -- ensure upstreams are initialized + + if not balancer_initialized then + balancer.init() + balancer_initialized = true + end + -- ensure router is up-to-date local version, err = singletons.cache:get("router:version", {