@@ -190,9 +190,11 @@ terminate(Reason, _State_Name,
190190% % @private
191191% % @doc Move to 'ACTIVE' if requested, otherwise stay in 'INACTIVE' state.
192192? inactive (activate , _From , # ef_state {config = Config , connection_sup = Conn_Sup } = State ) ->
193- Max_Sessions = elysium_config :session_max_count (Config ),
193+ Max_Sessions = elysium_config :session_max_count (Config ),
194+ Lb_Queue_Name = elysium_config :load_balancer_queue (Config ),
195+ Num_Nodes = ets_buffer :num_entries_dedicated (Lb_Queue_Name ),
194196 _ = [spawn_monitor (elysium_connection_sup , start_child , [Conn_Sup , [Config ]])
195- || _N <- lists :seq (1 , Max_Sessions )],
197+ || _N <- lists :seq (1 , Max_Sessions * Num_Nodes )],
196198 {reply , Max_Sessions , ? active , State };
197199? inactive (_Any , _From , # ef_state {} = State ) ->
198200 {reply , ok , ? inactive , State }.
@@ -227,9 +229,11 @@ terminate(Reason, _State_Name,
227229% % @private
228230% % @doc Activate if requested, from the 'INACTIVE' state.
229231? inactive (activate , # ef_state {config = Config , connection_sup = Conn_Sup } = State ) ->
230- Max_Sessions = elysium_config :session_max_count (Config ),
232+ Max_Sessions = elysium_config :session_max_count (Config ),
233+ Lb_Queue_Name = elysium_config :load_balancer_queue (Config ),
234+ Num_Nodes = ets_buffer :num_entries_dedicated (Lb_Queue_Name ),
231235 _ = [spawn_monitor (elysium_connection_sup , start_child , [Conn_Sup , [Config ]])
232- || _N <- lists :seq (1 , Max_Sessions )],
236+ || _N <- lists :seq (1 , Max_Sessions * Num_Nodes )],
233237 {next_state , ? active , State };
234238? inactive (_Other , # ef_state {} = State ) ->
235239 {next_state , ? inactive , State }.
0 commit comments