Skip to content

Commit

Permalink
Prefer application restarts than allowing reruns
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Dec 1, 2023
1 parent c287937 commit 6b22b8d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/amoc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
-export([do/3,
add/1,
remove/2,
stop/0]).
stop/0,
reset/0]).

-export_type([scenario/0]).
-type scenario() :: module().
Expand Down Expand Up @@ -56,6 +57,17 @@ stop() ->
Error -> Error
end.

-spec reset() -> ok | {error, term()}.
reset() ->
case is_running_locally() of
ok ->
application:stop(?MODULE),
application:ensure_all_started(?MODULE),
ok;
Error ->
Error
end.

%% ------------------------------------------------------------------
%% Local functions
%% ------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions src/amoc_controller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ handle_info(_Msg, State) ->
%% ------------------------------------------------------------------
-spec handle_start_scenario(module(), amoc_config:settings(), state()) ->
{handle_call_res(), state()}.
handle_start_scenario(Scenario, Settings, #state{status = Status} = State)
when Status =:= idle; Status =:= finished ->
handle_start_scenario(Scenario, Settings, #state{status = idle} = State) ->
case init_scenario(Scenario, Settings) of
{ok, ScenarioState} ->
NewState = State#state{last_user_id = 0,
Expand Down

0 comments on commit 6b22b8d

Please sign in to comment.