fix(bridge): update bridge with new conf failed

This commit is contained in:
Shawn 2021-09-15 11:39:32 +08:00
parent 7058b83760
commit b1999b2205
3 changed files with 48 additions and 48 deletions

View File

@ -2,48 +2,48 @@
## EMQ X Bridge
##--------------------------------------------------------------------
bridges.mqtt.my_mqtt_bridge_to_aws {
server = "127.0.0.1:1883"
proto_ver = "v4"
username = "username1"
password = ""
clean_start = true
keepalive = 300
retry_interval = "30s"
max_inflight = 32
reconnect_interval = "30s"
bridge_mode = true
replayq {
dir = "{{ platform_data_dir }}/replayq/bridge_mqtt/"
seg_bytes = "100MB"
offload = false
max_total_bytes = "1GB"
}
ssl {
enable = false
keyfile = "{{ platform_etc_dir }}/certs/client-key.pem"
certfile = "{{ platform_etc_dir }}/certs/client-cert.pem"
cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem"
}
## we will create one MQTT connection for each element of the `ingress_channels`
ingress_channels: [{
## the `id` will be used as part of the clientid
id = "pull_msgs_from_aws"
subscribe_remote_topic = "aws/#"
subscribe_qos = 1
local_topic = "from_aws/${topic}"
payload = "${payload}"
qos = "${qos}"
retain = "${retain}"
}]
## we will create one MQTT connection for each element of the `egress_channels`
egress_channels: [{
## the `id` will be used as part of the clientid
id = "push_msgs_to_aws"
subscribe_local_topic = "emqx/#"
remote_topic = "from_emqx/${topic}"
payload = "${payload}"
qos = 1
retain = false
}]
}
#bridges.mqtt.my_mqtt_bridge_to_aws {
# server = "127.0.0.1:1883"
# proto_ver = "v4"
# username = "username1"
# password = ""
# clean_start = true
# keepalive = 300
# retry_interval = "30s"
# max_inflight = 32
# reconnect_interval = "30s"
# bridge_mode = true
# replayq {
# dir = "{{ platform_data_dir }}/replayq/bridge_mqtt/"
# seg_bytes = "100MB"
# offload = false
# max_total_bytes = "1GB"
# }
# ssl {
# enable = false
# keyfile = "{{ platform_etc_dir }}/certs/client-key.pem"
# certfile = "{{ platform_etc_dir }}/certs/client-cert.pem"
# cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem"
# }
# ## we will create one MQTT connection for each element of the `ingress_channels`
# ingress_channels: [{
# ## the `id` will be used as part of the clientid
# id = "pull_msgs_from_aws"
# subscribe_remote_topic = "aws/#"
# subscribe_qos = 1
# local_topic = "from_aws/${topic}"
# payload = "${payload}"
# qos = "${qos}"
# retain = "${retain}"
# }]
# ## we will create one MQTT connection for each element of the `egress_channels`
# egress_channels: [{
# ## the `id` will be used as part of the clientid
# id = "push_msgs_to_aws"
# subscribe_local_topic = "emqx/#"
# remote_topic = "from_emqx/${topic}"
# payload = "${payload}"
# qos = 1
# retain = false
# }]
#}

View File

@ -149,7 +149,7 @@ create_bridge(Type, Name, Conf) ->
{error, Reason}
end.
update_bridge(Type, Name, Conf) ->
update_bridge(Type, Name, {_OldConf, Conf}) ->
%% TODO: sometimes its not necessary to restart the bridge connection.
%%
%% - if the connection related configs like `username` is updated, we should restart/start
@ -160,7 +160,7 @@ update_bridge(Type, Name, Conf) ->
%%
logger:info("update ~p bridge ~p use config: ~p", [Type, Name, Conf]),
emqx_resource:recreate(resource_id(Type, Name),
emqx_bridge:resource_type(Type), Conf).
emqx_bridge:resource_type(Type), Conf, []).
remove_bridge(Type, Name, _Conf) ->
logger:info("remove ~p bridge ~p", [Type, Name]),

View File

@ -168,7 +168,7 @@ create_sub_bridge(#{name := Name} = Conf) ->
{ok, _Pid} ->
start_sub_bridge(Name);
{error, {already_started, _Pid}} ->
ok;
{ok, Name};
{error, Reason} ->
{error, Reason}
end.