Skip to content

Commit 4661853

Browse files
committed
bug fix
1 parent 05d6edd commit 4661853

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/ra.erl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ start(Params) when is_list(Params) ->
140140
[ok = application:set_env(ra, Param, Value)
141141
|| {Param, Value} <- Params],
142142
Res = application:ensure_all_started(ra),
143-
ra_env:configure_logger(logger),
144143
_ = ra_system:start_default(),
145144
Res.
146145

@@ -153,6 +152,17 @@ start(Params) when is_list(Params) ->
153152
{ok, [Started]} | {error, term()}
154153
when Started :: term().
155154
start_in(DataDir) ->
155+
ra_env:configure_logger(logger),
156+
LogFile = filename:join(DataDir, "ra.log"),
157+
SaslFile = filename:join(DataDir, "ra_sasl.log"),
158+
logger:set_primary_config(level, debug),
159+
Config = #{config => #{file => LogFile}},
160+
logger:add_handler(ra_handler, logger_std_h, Config),
161+
application:load(sasl),
162+
application:set_env(sasl, sasl_error_logger, {file, SaslFile}),
163+
application:stop(sasl),
164+
application:start(sasl),
165+
_ = error_logger:tty(false),
156166
start([{data_dir, DataDir}]).
157167

158168
%% @doc Restarts a previously successfully started ra server

src/ra_server_proc.erl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ candidate(EventType, {aux_command, Cmd}, State0) ->
661661
{State, Actions} =
662662
?HANDLE_EFFECTS(Effects, EventType,
663663
State0#state{server_state = ServerState}),
664-
{keep_state, State#state{server_state = ServerState}, Actions};
664+
{keep_state, State, Actions};
665665
candidate({call, From}, ping, State) ->
666666
{keep_state, State, [{reply, From, {pong, candidate}}]};
667667
candidate(info, {node_event, _Node, _Evt}, State) ->
@@ -717,7 +717,7 @@ pre_vote(EventType, {aux_command, Cmd}, State0) ->
717717
{State, Actions} =
718718
?HANDLE_EFFECTS(Effects, EventType,
719719
State0#state{server_state = ServerState}),
720-
{keep_state, State#state{server_state = ServerState}, Actions};
720+
{keep_state, State, Actions};
721721
pre_vote({call, From}, ping, State) ->
722722
{keep_state, State, [{reply, From, {pong, pre_vote}}]};
723723
pre_vote(info, {node_event, _Node, _Evt}, State) ->
@@ -807,7 +807,7 @@ follower(EventType, {aux_command, Cmd}, State0) ->
807807
{State, Actions} =
808808
?HANDLE_EFFECTS(Effects, EventType,
809809
State0#state{server_state = ServerState}),
810-
{keep_state, State#state{server_state = ServerState}, Actions};
810+
{keep_state, State, Actions};
811811
follower({call, From}, trigger_election, State) ->
812812
?DEBUG("~ts: election triggered by ~w", [log_id(State), element(1, From)]),
813813
{keep_state, State, [{reply, From, ok},
@@ -933,7 +933,7 @@ receive_snapshot(EventType, {aux_command, Cmd}, State0) ->
933933
{State, Actions} =
934934
?HANDLE_EFFECTS(Effects, EventType,
935935
State0#state{server_state = ServerState}),
936-
{keep_state, State#state{server_state = ServerState}, Actions};
936+
{keep_state, State, Actions};
937937
receive_snapshot(EventType, Msg, State0) ->
938938
case handle_receive_snapshot(Msg, State0) of
939939
{receive_snapshot, State1, Effects} ->
@@ -1035,7 +1035,7 @@ await_condition(EventType, {aux_command, Cmd}, State0) ->
10351035
{State, Actions} =
10361036
?HANDLE_EFFECTS(Effects, EventType,
10371037
State0#state{server_state = ServerState}),
1038-
{keep_state, State#state{server_state = ServerState}, Actions};
1038+
{keep_state, State, Actions};
10391039
await_condition({call, From}, ping, State) ->
10401040
{keep_state, State, [{reply, From, {pong, await_condition}}]};
10411041
await_condition({call, From}, trigger_election, State) ->

0 commit comments

Comments
 (0)