fix timeout
This commit is contained in:
parent
dc50a33d88
commit
8d6e813608
@ -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} ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user