fix codec
This commit is contained in:
parent
e1256552b9
commit
175e4b6a81
@ -44,12 +44,11 @@ handle_request("GET", "/host/status", #{<<"uuid">> := UUID}, _) when is_binary(U
|
|||||||
|
|
||||||
%% 删除对应的主机信息
|
%% 删除对应的主机信息
|
||||||
handle_request("POST", "/host/delete", _, #{<<"uuid">> := UUID}) when is_binary(UUID) ->
|
handle_request("POST", "/host/delete", _, #{<<"uuid">> := UUID}) when is_binary(UUID) ->
|
||||||
case iot_host_sup:delete_host(UUID) of
|
case iot_host:get_pid(UUID) of
|
||||||
ok ->
|
Pid when is_pid(Pid) ->
|
||||||
lager:debug("[host_handler] will delete host uuid: ~p", [UUID]),
|
ok = iot_host_sup:delete_host(UUID),
|
||||||
{ok, 200, iot_util:json_data(<<"success">>)};
|
{ok, 200, iot_util:json_data(<<"success">>)};
|
||||||
{error, Reason} ->
|
undefined ->
|
||||||
lager:debug("[host_handler] delete host uuid: ~p, get error is: ~p", [UUID, Reason]),
|
|
||||||
{ok, 200, iot_util:json_error(404, <<"error">>)}
|
{ok, 200, iot_util:json_error(404, <<"error">>)}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -37,13 +37,7 @@ ensured_host_started(UUID) when is_binary(UUID) ->
|
|||||||
|
|
||||||
delete_host(UUID) ->
|
delete_host(UUID) ->
|
||||||
Id = iot_host:get_name(UUID),
|
Id = iot_host:get_name(UUID),
|
||||||
case supervisor:terminate_child(?MODULE, Id) of
|
ok = supervisor:terminate_child(?MODULE, Id),
|
||||||
{error, running} ->
|
|
||||||
iot_host:kill(UUID),
|
|
||||||
ok;
|
|
||||||
_ ->
|
|
||||||
ok
|
|
||||||
end,
|
|
||||||
case supervisor:delete_child(?MODULE, Id) of
|
case supervisor:delete_child(?MODULE, Id) of
|
||||||
{error, running} ->
|
{error, running} ->
|
||||||
%% ensure killed then delete again
|
%% ensure killed then delete again
|
||||||
|
|||||||
@ -113,7 +113,7 @@ decode0(_, _) ->
|
|||||||
%%% helper methods
|
%%% helper methods
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
-spec marshal(Type :: integer(), Field :: any()) -> binary().
|
-spec marshal(Type :: ?I8 | ?I16 | ?I32 | ?Bytes, Field :: integer() | binary()) -> binary().
|
||||||
marshal(?I8, Field) when is_integer(Field) ->
|
marshal(?I8, Field) when is_integer(Field) ->
|
||||||
<<?I8, Field:8>>;
|
<<?I8, Field:8>>;
|
||||||
marshal(?I16, Field) when is_integer(Field) ->
|
marshal(?I16, Field) when is_integer(Field) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user