fix(data-import): fix import rule fail (#5512)
This commit is contained in:
parent
6aa61ea78d
commit
ea15aa3f9e
|
@ -67,6 +67,8 @@
|
|||
!./bin/emqx_ctl rules create 'SELECT * FROM "t/#"' '[{"name":"data_to_webserver", "params": {"$$resource": "resource:691c29ba"}}]'
|
||||
?created
|
||||
?SH-PROMPT
|
||||
?sleep 5
|
||||
?SH-PROMPT
|
||||
|
||||
[shell emqx]
|
||||
!./bin/emqx_ctl resources list
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{application, emqx_management,
|
||||
[{description, "EMQ X Management API and CLI"},
|
||||
{vsn, "4.3.5"}, % strict semver, bump manually!
|
||||
{vsn, "4.3.6"}, % strict semver, bump manually!
|
||||
{modules, []},
|
||||
{registered, [emqx_management_sup]},
|
||||
{applications, [kernel,stdlib,minirest]},
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
%% -*- mode: erlang -*-
|
||||
{VSN,
|
||||
[ {<<"4.3.[0-4]">>,
|
||||
[ {<<"4.3.[0-5]">>,
|
||||
[ {apply,{minirest,stop_http,['http:management']}},
|
||||
{apply,{minirest,stop_http,['https:management']}},
|
||||
{restart_application, emqx_management}
|
||||
]},
|
||||
{<<".*">>, []}
|
||||
],
|
||||
[ {<<"4.3.[0-4]">>,
|
||||
[ {<<"4.3.[0-5]">>,
|
||||
[ {apply,{minirest,stop_http,['http:management']}},
|
||||
{apply,{minirest,stop_http,['https:management']}},
|
||||
{restart_application, emqx_management}
|
||||
|
|
|
@ -185,6 +185,7 @@ confs_to_binary(Confs) ->
|
|||
|
||||
-endif.
|
||||
|
||||
-dialyzer([{nowarn_function, [import_rules/1, import_rule/1]}]).
|
||||
import_rule(#{<<"id">> := RuleId,
|
||||
<<"rawsql">> := RawSQL,
|
||||
<<"actions">> := Actions,
|
||||
|
@ -195,9 +196,11 @@ import_rule(#{<<"id">> := RuleId,
|
|||
actions => map_to_actions(Actions),
|
||||
enabled => Enabled,
|
||||
description => Desc},
|
||||
try emqx_rule_engine:create_rule(Rule)
|
||||
catch throw:{resource_not_initialized, _ResId} ->
|
||||
emqx_rule_engine:create_rule(Rule#{enabled => false})
|
||||
case emqx_rule_engine:create_rule(Rule) of
|
||||
{ok, _} -> ok;
|
||||
{error, _} ->
|
||||
_ = emqx_rule_engine:create_rule(Rule#{enabled => false}),
|
||||
ok
|
||||
end.
|
||||
|
||||
map_to_actions(Maps) ->
|
||||
|
|
Loading…
Reference in New Issue