Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Gracefully handle dropped connections

Thanks to langxianzhe@ for the initial patch
  • Loading branch information...
commit a944735cf6a97692112730fbf513205308463779 1 parent cbbb45e
Evan Miller authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/boss_db_controller.erl
View
5 src/boss_db_controller.erl
@@ -27,6 +27,7 @@ init(Options) ->
Adapter = list_to_atom(lists:concat(["boss_db_adapter_", AdapterName])),
CacheEnable = proplists:get_value(cache_enable, Options, false),
CacheTTL = proplists:get_value(cache_exp_time, Options, 60),
+ process_flag(trap_exit, true),
{ok, Conn} = Adapter:init(Options),
{Shards, ModelDict} = lists:foldr(fun(ShardOptions, {ShardAcc, ModelDictAcc}) ->
case proplists:get_value(db_shard_models, ShardOptions, []) of
@@ -156,6 +157,10 @@ terminate(_Reason, State) ->
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
+handle_info(stop, State) ->
+ {stop, shutdown, State};
+handle_info({'EXIT', _, _}, State) ->
+ {stop, shutdown, State};
handle_info(_Info, State) ->
{noreply, State}.
Please sign in to comment.
Something went wrong with that request. Please try again.