diff --git a/apps/iot/src/http/endpoint_handler.erl b/apps/iot/src/http/endpoint_handler.erl index e5a2a7a..18ea043 100644 --- a/apps/iot/src/http/endpoint_handler.erl +++ b/apps/iot/src/http/endpoint_handler.erl @@ -17,6 +17,18 @@ %% helper methods %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% 获取endpoint的运行状态 +handle_request("POST", "/endpoint/run_statuses", _, Ids) when is_list(Ids) -> + Statuses = lists:map(fun(Id) -> + case endpoint:get_pid(Id) of + undefined -> + 0; + Pid when is_pid(Pid) -> + 1 + end + end, Ids), + {ok, 200, iot_util:json_data(Statuses)}; + handle_request("POST", "/endpoint/start", _, #{<<"id">> := Id}) when is_integer(Id) -> case endpoint_bo:get_endpoint(Id) of undefined ->