fix
This commit is contained in:
parent
1993917a68
commit
4e754cba78
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
-record(state, {
|
-record(state, {
|
||||||
root_dir :: string(),
|
root_dir :: string(),
|
||||||
%% 建立任务到ref之间的映射, #{MRef => taskId}
|
%% 建立任务到ref之间的映射, #{TaskPid => {TaskId, ServiceId}}
|
||||||
task_map = #{}
|
task_map = #{}
|
||||||
}).
|
}).
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ handle_call({deploy, TaskId, ServiceId, TarUrl}, _From, State = #state{root_dir
|
|||||||
{ok, TaskPid} = efka_inetd_task:start_link(TaskId, RootDir, ServiceId, TarUrl),
|
{ok, TaskPid} = efka_inetd_task:start_link(TaskId, RootDir, ServiceId, TarUrl),
|
||||||
efka_inetd_task:deploy(TaskPid),
|
efka_inetd_task:deploy(TaskPid),
|
||||||
|
|
||||||
{reply, ok, State};
|
{reply, ok, State#state{task_map = maps:put(TaskPid, {TaskId, ServiceId}, TaskMap)}};
|
||||||
|
|
||||||
handle_call(_Request, _From, State = #state{}) ->
|
handle_call(_Request, _From, State = #state{}) ->
|
||||||
{reply, ok, State}.
|
{reply, ok, State}.
|
||||||
@ -93,14 +93,22 @@ handle_cast(_Request, State = #state{}) ->
|
|||||||
{noreply, NewState :: #state{}} |
|
{noreply, NewState :: #state{}} |
|
||||||
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
||||||
{stop, Reason :: term(), NewState :: #state{}}).
|
{stop, Reason :: term(), NewState :: #state{}}).
|
||||||
%% 下载任务异常退出
|
handle_info({'EXIT', TaskPid, Reason}, State = #state{task_map = TaskMap}) ->
|
||||||
handle_info({'DOWN', Ref, process, _Pid, {error, Reason}}, State = #state{task_map = TaskMap}) ->
|
case maps:take(TaskPid, TaskMap) of
|
||||||
{{TaskId, _Service}, NTaskMap} = maps:take(Ref, TaskMap),
|
error ->
|
||||||
lager:debug("[efka_inetd] service: ~p, download get error: ~p", [Reason]),
|
{noreply, State};
|
||||||
%% 下载完整
|
{{TaskId, ServiceId}, NTaskMap} ->
|
||||||
efka_agent:feedback_phase(TaskId, efka_util:timestamp(), <<"download">>, 0),
|
case Reason of
|
||||||
|
normal ->
|
||||||
{noreply, State#state{task_map = NTaskMap}};
|
lager:debug("[efka_inetd] service_id: ~p, task_pid: ~p, exit normal", [ServiceId, TaskPid]),
|
||||||
|
efka_agent:feedback_phase(TaskId, efka_util:timestamp(), <<"completed">>, 1);
|
||||||
|
Error ->
|
||||||
|
lager:debug("[efka_inetd] service_id: ~p, task_pid: ~p, exit with error: ~p", [ServiceId, TaskPid, Error]),
|
||||||
|
%% 下载完整
|
||||||
|
efka_agent:feedback_phase(TaskId, efka_util:timestamp(), <<"aborted">>, 0),
|
||||||
|
{noreply, State#state{task_map = NTaskMap}}
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
|
||||||
handle_info(_Info, State = #state{}) ->
|
handle_info(_Info, State = #state{}) ->
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user