diff --git a/apps/iot/src/iot_device_sup.erl b/apps/iot/src/iot_device_sup.erl index 9b9d26d..bab1393 100644 --- a/apps/iot/src/iot_device_sup.erl +++ b/apps/iot/src/iot_device_sup.erl @@ -25,6 +25,9 @@ init([]) -> ensured_device_started(DeviceUUID) when is_binary(DeviceUUID) -> case iot_device:get_pid(DeviceUUID) of undefined -> + %% 先删除,然后添加 + Id = iot_device:get_name(DeviceUUID), + supervisor:delete_child(?MODULE, Id), case supervisor:start_child(?MODULE, child_spec(DeviceUUID)) of {ok, Pid} when is_pid(Pid) -> {ok, Pid};