This commit is contained in:
anlicheng 2025-05-06 15:55:12 +08:00
parent 9a6db565e8
commit 4d4ec3ad5f
3 changed files with 44 additions and 8 deletions

View File

@ -16,7 +16,7 @@
%% API %% API
-export([start_link/0]). -export([start_link/0]).
-export([data/5, event/2, ai_event/2]). -export([data/5, event/2, ai_event/2, feedback_phase/1]).
%% gen_server callbacks %% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
@ -63,10 +63,7 @@ ping(AdCode, BootTime, Province, City, EfkaVersion, KernelArch, Ips, CpuCore, Cp
}, },
gen_server:cast(?SERVER, {ping, Ping}). gen_server:cast(?SERVER, {ping, Ping}).
service_inform() -> feedback_phase(Phase) ->
ok.
feedback_step() ->
ok. ok.
feedback_result() -> feedback_result() ->

View File

@ -11,6 +11,7 @@
-module(efka_inetd). -module(efka_inetd).
-author("anlicheng"). -author("anlicheng").
-include("efka_tables.hrl"). -include("efka_tables.hrl").
-include("message_pb.hrl").
-behaviour(gen_server). -behaviour(gen_server).
@ -124,15 +125,53 @@ handle_info({'DOWN', Ref, process, _Pid, Reason}, State = #state{task_map = Task
%% taskId的执行进度 %% taskId的执行进度
case Reason of case Reason of
normal -> normal ->
%%
DownloadPhase = #feedback_phase{
task_id = TaskId,
timestamp = efka_util:timestamp(),
phase = <<"download">>,
code = 1,
message = <<"">>
},
efka_agent:feedback_phase(DownloadPhase),
%% %%
case start_service(Service) of case start_service(Service) of
{ok, Pid} -> {ok, Pid} when is_pid(Pid) ->
BootPhase = #feedback_phase{
task_id = TaskId,
timestamp = efka_util:timestamp(),
phase = <<"boot">>,
code = 1,
message = <<"">>
},
efka_agent:feedback_phase(BootPhase),
micro_service_model:insert(Service#micro_service{status = 1}); micro_service_model:insert(Service#micro_service{status = 1});
{error, Reason} -> {error, Reason} ->
BootPhase = #feedback_phase{
task_id = TaskId,
timestamp = efka_util:timestamp(),
phase = <<"boot">>,
code = 0,
message = <<"启动失败"/utf8>>
},
efka_agent:feedback_phase(BootPhase),
micro_service_model:insert(Service#micro_service{status = 0}) micro_service_model:insert(Service#micro_service{status = 0})
end; end;
{error, Reason} -> {error, Reason} ->
lager:debug("[efka_inetd] service: ~p, download get error: ~p", [Reason]), lager:debug("[efka_inetd] service: ~p, download get error: ~p", [Reason]),
%%
DownloadPhase = #feedback_phase{
task_id = TaskId,
timestamp = efka_util:timestamp(),
phase = <<"download">>,
code = 0,
message = <<"下载失败"/utf8>>
},
efka_agent:feedback_phase(DownloadPhase),
{noreply, State#state{task_map = NTaskMap}} {noreply, State#state{task_map = NTaskMap}}
end end
end; end;
@ -194,9 +233,8 @@ check_download_url(Url) when is_list(Url) ->
{verify, verify_none} {verify, verify_none}
]} ]}
], ],
case httpc:request(head, {Url, []}, SslOpts, [{sync, true}]) of case httpc:request(head, {Url, []}, SslOpts, [{sync, true}]) of
{ok, {{_, 200, "OK"}, Headers, _}} -> {ok, {{_, 200, "OK"}, _Headers, _}} ->
ok; ok;
{error, Reason} -> {error, Reason} ->
{error, Reason} {error, Reason}

View File

@ -98,6 +98,7 @@ message FeedbackPhase {
string task_id = 1; string task_id = 1;
uint32 timestamp = 2; uint32 timestamp = 2;
string phase = 3; string phase = 3;
// 0 , 1
uint32 code = 4; uint32 code = 4;
string message = 5; string message = 5;
} }