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