fix(rules): load rules from config file failed
This commit is contained in:
parent
c6c314de1a
commit
467805855d
|
@ -163,7 +163,6 @@ unload_hooks_for_rule(#{id := Id, from := Topics}) ->
|
|||
init([]) ->
|
||||
_TableId = ets:new(?KV_TAB, [named_table, set, public, {write_concurrency, true},
|
||||
{read_concurrency, true}]),
|
||||
ok = load_rules(),
|
||||
{ok, #{}}.
|
||||
|
||||
handle_call({insert_rule, Rule}, _From, State) ->
|
||||
|
|
|
@ -273,8 +273,6 @@ crud_rules_by_id(put, #{bindings := #{id := Id}, body := Params0}) ->
|
|||
Params = maps:merge(Params0, #{id => Id}),
|
||||
?CHECK_PARAMS(Params, rule_creation, case emqx_rule_engine:update_rule(CheckedParams) of
|
||||
{ok, Rule} -> {200, format_rule_resp(Rule)};
|
||||
{error, not_found} ->
|
||||
{404, #{code => 'NOT_FOUND', message => <<"Rule Id Not Found">>}};
|
||||
{error, Reason} ->
|
||||
?SLOG(error, #{msg => "update_rule_failed",
|
||||
id => Id,
|
||||
|
@ -283,10 +281,8 @@ crud_rules_by_id(put, #{bindings := #{id := Id}, body := Params0}) ->
|
|||
end);
|
||||
|
||||
crud_rules_by_id(delete, #{bindings := #{id := Id}}) ->
|
||||
case emqx_rule_engine:delete_rule(Id) of
|
||||
ok -> {200};
|
||||
{error, not_found} -> {200}
|
||||
end.
|
||||
ok = emqx_rule_engine:delete_rule(Id),
|
||||
{200}.
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
%% Internal functions
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
start(_Type, _Args) ->
|
||||
_ = ets:new(?RULE_TAB, [named_table, public, set, {read_concurrency, true}]),
|
||||
ok = emqx_rule_events:reload(),
|
||||
emqx_rule_engine_sup:start_link().
|
||||
SupRet = emqx_rule_engine_sup:start_link(),
|
||||
ok = emqx_rule_engine:load_rules(),
|
||||
SupRet.
|
||||
|
||||
stop(_State) ->
|
||||
ok = emqx_rule_events:unload().
|
||||
|
|
Loading…
Reference in New Issue