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([]) ->
|
init([]) ->
|
||||||
_TableId = ets:new(?KV_TAB, [named_table, set, public, {write_concurrency, true},
|
_TableId = ets:new(?KV_TAB, [named_table, set, public, {write_concurrency, true},
|
||||||
{read_concurrency, true}]),
|
{read_concurrency, true}]),
|
||||||
ok = load_rules(),
|
|
||||||
{ok, #{}}.
|
{ok, #{}}.
|
||||||
|
|
||||||
handle_call({insert_rule, Rule}, _From, State) ->
|
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}),
|
Params = maps:merge(Params0, #{id => Id}),
|
||||||
?CHECK_PARAMS(Params, rule_creation, case emqx_rule_engine:update_rule(CheckedParams) of
|
?CHECK_PARAMS(Params, rule_creation, case emqx_rule_engine:update_rule(CheckedParams) of
|
||||||
{ok, Rule} -> {200, format_rule_resp(Rule)};
|
{ok, Rule} -> {200, format_rule_resp(Rule)};
|
||||||
{error, not_found} ->
|
|
||||||
{404, #{code => 'NOT_FOUND', message => <<"Rule Id Not Found">>}};
|
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?SLOG(error, #{msg => "update_rule_failed",
|
?SLOG(error, #{msg => "update_rule_failed",
|
||||||
id => Id,
|
id => Id,
|
||||||
|
@ -283,10 +281,8 @@ crud_rules_by_id(put, #{bindings := #{id := Id}, body := Params0}) ->
|
||||||
end);
|
end);
|
||||||
|
|
||||||
crud_rules_by_id(delete, #{bindings := #{id := Id}}) ->
|
crud_rules_by_id(delete, #{bindings := #{id := Id}}) ->
|
||||||
case emqx_rule_engine:delete_rule(Id) of
|
ok = emqx_rule_engine:delete_rule(Id),
|
||||||
ok -> {200};
|
{200}.
|
||||||
{error, not_found} -> {200}
|
|
||||||
end.
|
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
|
|
|
@ -27,7 +27,9 @@
|
||||||
start(_Type, _Args) ->
|
start(_Type, _Args) ->
|
||||||
_ = ets:new(?RULE_TAB, [named_table, public, set, {read_concurrency, true}]),
|
_ = ets:new(?RULE_TAB, [named_table, public, set, {read_concurrency, true}]),
|
||||||
ok = emqx_rule_events:reload(),
|
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) ->
|
stop(_State) ->
|
||||||
ok = emqx_rule_events:unload().
|
ok = emqx_rule_events:unload().
|
||||||
|
|
Loading…
Reference in New Issue