From 8d6e8136085ae388587a3a28fc16df379ff54a73 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Tue, 28 Oct 2025 22:45:28 +0800 Subject: [PATCH] fix timeout --- apps/iot/src/http_handlers/container_handler.erl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/iot/src/http_handlers/container_handler.erl b/apps/iot/src/http_handlers/container_handler.erl index d384e46..433315b 100644 --- a/apps/iot/src/http_handlers/container_handler.erl +++ b/apps/iot/src/http_handlers/container_handler.erl @@ -10,6 +10,8 @@ -author("licheng5"). -include("iot.hrl"). +-define(REQ_TIMEOUT, 10000). + %% API -export([handle_request/4]). @@ -21,7 +23,7 @@ handle_request("GET", "/container/get_all", #{<<"uuid">> := UUID}, _) when is_bi Pid when is_pid(Pid) -> case iot_host:get_containers(Pid) of {ok, Ref} -> - case iot_host:await_reply(Ref, 10000) of + case iot_host:await_reply(Ref, ?REQ_TIMEOUT) of {ok, Result} -> {ok, 200, iot_util:json_data(Result)}; {error, Reason} -> @@ -67,7 +69,7 @@ handle_request("POST", "/container/deploy", _, #{<<"uuid">> := UUID, <<"task_id" Pid when is_pid(Pid) -> case iot_host:deploy_container(Pid, TaskId, Config) of {ok, Ref} -> - case iot_host:await_reply(Ref, 5000) of + case iot_host:await_reply(Ref, ?REQ_TIMEOUT) of {ok, Result} -> {ok, 200, iot_util:json_data(Result)}; {error, Reason} -> @@ -86,7 +88,7 @@ handle_request("POST", "/container/start", _, #{<<"uuid">> := UUID, <<"container Pid when is_pid(Pid) -> case iot_host:start_container(Pid, ContainerName) of {ok, Ref} -> - case iot_host:await_reply(Ref, 5000) of + case iot_host:await_reply(Ref, ?REQ_TIMEOUT) of {ok, Result} -> {ok, 200, iot_util:json_data(Result)}; {error, Reason} -> @@ -105,7 +107,7 @@ handle_request("POST", "/container/stop", _, #{<<"uuid">> := UUID, <<"container_ Pid when is_pid(Pid) -> case iot_host:stop_container(Pid, ContainerName) of {ok, Ref} -> - case iot_host:await_reply(Ref, 5000) of + case iot_host:await_reply(Ref, ?REQ_TIMEOUT) of {ok, Result} -> {ok, 200, iot_util:json_data(Result)}; {error, Reason} -> @@ -123,7 +125,7 @@ handle_request("POST", "/container/kill", _, #{<<"uuid">> := UUID, <<"container_ Pid when is_pid(Pid) -> case iot_host:kill_container(Pid, ContainerName) of {ok, Ref} -> - case iot_host:await_reply(Ref, 5000) of + case iot_host:await_reply(Ref, ?REQ_TIMEOUT) of {ok, Result} -> {ok, 200, iot_util:json_data(Result)}; {error, Reason} -> @@ -142,7 +144,7 @@ handle_request("POST", "/container/remove", _, #{<<"uuid">> := UUID, <<"containe Pid when is_pid(Pid) -> case iot_host:remove_container(Pid, ContainerName) of {ok, Ref} -> - case iot_host:await_reply(Ref, 5000) of + case iot_host:await_reply(Ref, ?REQ_TIMEOUT) of {ok, Result} -> {ok, 200, iot_util:json_data(Result)}; {error, Reason} ->