fix
This commit is contained in:
parent
97571c702d
commit
37123da219
@ -21,7 +21,7 @@
|
||||
handle_request("POST", "/device/reload", _, #{<<"host_id">> := HostId, <<"device_uuid">> := DeviceUUID}) when is_binary(DeviceUUID) ->
|
||||
lager:debug("[device_handler] host_id: ~p, will reload device uuid: ~p", [HostId, DeviceUUID]),
|
||||
AliasName = iot_host:get_alias_name(HostId),
|
||||
case whereis(AliasName) of
|
||||
case global:whereis_name(AliasName) of
|
||||
undefined ->
|
||||
{ok, 200, iot_util:json_error(404, <<"reload device failed">>)};
|
||||
HostPid when is_pid(HostPid) ->
|
||||
@ -37,7 +37,7 @@ handle_request("POST", "/device/reload", _, #{<<"host_id">> := HostId, <<"device
|
||||
%% 删除对应的主机信息
|
||||
handle_request("POST", "/device/delete", _, #{<<"host_id">> := HostId, <<"device_uuid">> := DeviceUUID}) when is_binary(DeviceUUID) ->
|
||||
AliasName = iot_host:get_alias_name(HostId),
|
||||
case whereis(AliasName) of
|
||||
case global:whereis_name(AliasName) of
|
||||
undefined ->
|
||||
{ok, 200, iot_util:json_error(404, <<"delete device failed">>)};
|
||||
HostPid when is_pid(HostPid) ->
|
||||
@ -48,7 +48,7 @@ handle_request("POST", "/device/delete", _, #{<<"host_id">> := HostId, <<"device
|
||||
%% 处理主机的授权的激活
|
||||
handle_request("POST", "/device/activate", _, #{<<"host_id">> := HostId, <<"device_uuid">> := DeviceUUID, <<"auth">> := Auth}) when is_binary(DeviceUUID) ->
|
||||
AliasName = iot_host:get_alias_name(HostId),
|
||||
case whereis(AliasName) of
|
||||
case global:whereis_name(AliasName) of
|
||||
undefined ->
|
||||
{ok, 200, iot_util:json_error(404, <<"activate device failed">>)};
|
||||
HostPid when is_pid(HostPid) ->
|
||||
|
||||
@ -164,7 +164,7 @@ init([UUID]) ->
|
||||
|
||||
%% 通过host_id注册别名, 可以避免通过查询数据库获取HostPid
|
||||
AliasName = get_alias_name(HostId),
|
||||
erlang:register(AliasName, self()),
|
||||
global:register_name(AliasName, self()),
|
||||
|
||||
{ok, StateName, #state{host_id = HostId, uuid = UUID, aes = Aes}};
|
||||
undefined ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user