fix config

This commit is contained in:
anlicheng 2025-06-03 18:44:10 +08:00
parent 20c22a0df7
commit ad38e22d4a
5 changed files with 34 additions and 19 deletions

View File

@ -15,6 +15,11 @@
inets,
ssl,
public_key,
%erts,
%runtime_tools,
%observer,
kernel,
stdlib
]},

View File

@ -0,0 +1,25 @@
%%%-------------------------------------------------------------------
%%% @author anlicheng
%%% @copyright (C) 2025, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 03. 6 2025 14:09
%%%-------------------------------------------------------------------
-module(efka_monitor).
-author("anlicheng").
%% API
-export([]).
%% API
-export([memory_top/1, cpu_top/1, stop/0]).
memory_top(Interval) when is_integer(Interval) ->
spawn(fun()->etop:start([{output, text}, {interval, Interval}, {lines, 20}, {sort, memory}])end).
cpu_top(Interval) when is_integer(Interval) ->
spawn(fun()->etop:start([{output, text}, {interval, Interval}, {lines, 20}, {sort, runtime}])end).
stop() ->
etop:stop().

View File

@ -98,9 +98,6 @@ init([ServiceId]) ->
lager:notice("[efka_service] service_id: ~p, not found", [ServiceId]),
ignore;
{ok, #service{root_dir = RootDir}} ->
%%
try_update_config(ServiceId),
%%
case efka_manifest:new(RootDir) of
{ok, Manifest} ->
@ -291,17 +288,3 @@ trigger_callback(Ref, Callbacks) ->
catch Fun(),
NCallbacks
end.
-spec try_update_config(ServiceId :: binary()) -> no_return().
try_update_config(ServiceId) when is_binary(ServiceId) ->
case efka_agent:request_service_config(self(), ServiceId) of
{ok, Ref} ->
case efka_agent:await_reply(Ref, 5000) of
{ok, ConfigJson} ->
service_model:set_config(ServiceId, ConfigJson);
{error, Reason} ->
lager:debug("[efka_service] request_config get error: ~p", [Reason])
end;
{error, Reason} ->
lager:debug("[efka_service] request_config get error: ~p", [Reason])
end.

View File

@ -61,11 +61,12 @@ async_call_reply(undefined, PacketId, Response) when is_integer(PacketId), is_bi
async_call_reply(Pid, PacketId, Response) when is_pid(Pid), is_integer(PacketId), is_binary(Response) ->
gen_server:cast(Pid, {async_call_reply, PacketId, Response}).
%% transport进程已经退出了
-spec stop(Pid :: pid() | undefined) -> ok.
stop(undefined) ->
ok;
stop(Pid) when is_pid(Pid) ->
gen_server:stop(Pid, normal, 2000).
catch gen_server:stop(Pid, normal, 2000).
%% @doc Spawns the server and registers the local name (unique)
-spec(start_monitor(ParentPid :: pid(), Host :: string(), Port :: integer()) ->

View File

@ -1,6 +1,7 @@
-name efka
-setcookie efka_cookie
-kernel start_group false
-mnesia dir '"/usr/local/var/mnesia/efka"'
-mnesia dump_log_write_threshold 5000