From a507052d66023e36dc75d85054db24d000c6ea71 Mon Sep 17 00:00:00 2001 From: ttt161 Date: Wed, 18 Sep 2024 09:08:10 +0300 Subject: [PATCH] TD-927: add connections log --- src/epg_pool_wrk.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/epg_pool_wrk.erl b/src/epg_pool_wrk.erl index c85a51f..2b644e9 100644 --- a/src/epg_pool_wrk.erl +++ b/src/epg_pool_wrk.erl @@ -29,9 +29,10 @@ handle_cast(_Request, State = #epg_pool_wrk_state{}) -> handle_info( {'EXIT', Pid, _Info}, - State = #epg_pool_wrk_state{pool = _Pool, connection = Pid} + State = #epg_pool_wrk_state{pool = Pool, connection = Pid, params = #{database := DB}} ) -> %epg_pool_mgr:remove(Pool, self(), Pid), + logger:error("db connection lost. pool: ~p. database: ~p", [Pool, DB]), reconnect_timer(), {noreply, State#epg_pool_wrk_state{connection = undefined, monitor = undefined}}; @@ -50,10 +51,11 @@ code_change(_OldVsn, State = #epg_pool_wrk_state{}, _Extra) -> reconnect_timer() -> erlang:start_timer(5000, self(), reconnect). -connect(#epg_pool_wrk_state{pool = Pool, params = Params} = State) -> +connect(#epg_pool_wrk_state{pool = Pool, params = #{database := DB} = Params} = State) -> try epgsql:connect(Params) of {ok, Connection} -> epg_pool_mgr:add(Pool, self(), Connection), + logger:info("db connection established. pool: ~p. database: ~p", [Pool, DB]), State#epg_pool_wrk_state{connection = Connection}; {error, _Reason} -> reconnect_timer(),