simple code
This commit is contained in:
parent
4a81d1f6f9
commit
3ac8b18c98
@ -8,24 +8,6 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-author("anlicheng").
|
-author("anlicheng").
|
||||||
|
|
||||||
%% 用来保存微服务
|
|
||||||
-record(service, {
|
|
||||||
service_id :: binary(),
|
|
||||||
tar_url :: binary(),
|
|
||||||
%% 工作目录
|
|
||||||
root_dir :: string(),
|
|
||||||
%% 配置信息
|
|
||||||
config_json :: binary(),
|
|
||||||
%% 状态: 0: 停止, 1: 运行中
|
|
||||||
status = 0
|
|
||||||
}).
|
|
||||||
|
|
||||||
%% 数据缓存
|
|
||||||
-record(task_log, {
|
|
||||||
task_id = 0 :: integer(),
|
|
||||||
logs = []:: list()
|
|
||||||
}).
|
|
||||||
|
|
||||||
%% id生成器
|
%% id生成器
|
||||||
-record(id_generator, {
|
-record(id_generator, {
|
||||||
id,
|
id,
|
||||||
|
|||||||
@ -17,11 +17,6 @@
|
|||||||
inets,
|
inets,
|
||||||
ssl,
|
ssl,
|
||||||
public_key,
|
public_key,
|
||||||
|
|
||||||
%erts,
|
|
||||||
%runtime_tools,
|
|
||||||
%observer,
|
|
||||||
|
|
||||||
kernel,
|
kernel,
|
||||||
stdlib
|
stdlib
|
||||||
]},
|
]},
|
||||||
|
|||||||
@ -20,6 +20,7 @@ start(_StartType, _StartArgs) ->
|
|||||||
stop(_State) ->
|
stop(_State) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
%% 微服务和efka之间通过websocket协议通讯
|
||||||
start_ws_server() ->
|
start_ws_server() ->
|
||||||
{ok, Props} = application:get_env(efka, ws_server),
|
{ok, Props} = application:get_env(efka, ws_server),
|
||||||
Acceptors = proplists:get_value(acceptors, Props, 50),
|
Acceptors = proplists:get_value(acceptors, Props, 50),
|
||||||
|
|||||||
@ -1,74 +0,0 @@
|
|||||||
%%%-------------------------------------------------------------------
|
|
||||||
%%% @author anlicheng
|
|
||||||
%%% @copyright (C) 2025, <COMPANY>
|
|
||||||
%%% @doc
|
|
||||||
%%%
|
|
||||||
%%% @end
|
|
||||||
%%% Created : 18. 4月 2025 16:42
|
|
||||||
%%%-------------------------------------------------------------------
|
|
||||||
-module(efka_model_sup).
|
|
||||||
-author("anlicheng").
|
|
||||||
-include("efka_tables.hrl").
|
|
||||||
|
|
||||||
-behaviour(supervisor).
|
|
||||||
|
|
||||||
%% API
|
|
||||||
-export([start_link/0]).
|
|
||||||
|
|
||||||
%% Supervisor callbacks
|
|
||||||
-export([init/1]).
|
|
||||||
|
|
||||||
-define(SERVER, ?MODULE).
|
|
||||||
|
|
||||||
%%%===================================================================
|
|
||||||
%%% API functions
|
|
||||||
%%%===================================================================
|
|
||||||
|
|
||||||
%% @doc Starts the supervisor
|
|
||||||
-spec(start_link() -> {ok, Pid :: pid()} | ignore | {error, Reason :: term()}).
|
|
||||||
start_link() ->
|
|
||||||
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
|
|
||||||
|
|
||||||
%%%===================================================================
|
|
||||||
%%% Supervisor callbacks
|
|
||||||
%%%===================================================================
|
|
||||||
|
|
||||||
%% @private
|
|
||||||
%% @doc Whenever a supervisor is started using supervisor:start_link/[2,3],
|
|
||||||
%% this function is called by the new process to find out about
|
|
||||||
%% restart strategy, maximum restart frequency and child
|
|
||||||
%% specifications.
|
|
||||||
init([]) ->
|
|
||||||
SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600},
|
|
||||||
Specs = [
|
|
||||||
#{
|
|
||||||
id => cache_model,
|
|
||||||
start => {cache_model, start_link, []},
|
|
||||||
restart => permanent,
|
|
||||||
shutdown => 5000,
|
|
||||||
type => worker,
|
|
||||||
modules => ['cache_model']
|
|
||||||
},
|
|
||||||
#{
|
|
||||||
id => service_model,
|
|
||||||
start => {service_model, start_link, []},
|
|
||||||
restart => permanent,
|
|
||||||
shutdown => 5000,
|
|
||||||
type => worker,
|
|
||||||
modules => ['service_model']
|
|
||||||
},
|
|
||||||
#{
|
|
||||||
id => task_log_model,
|
|
||||||
start => {task_log_model, start_link, []},
|
|
||||||
restart => permanent,
|
|
||||||
shutdown => 5000,
|
|
||||||
type => worker,
|
|
||||||
modules => ['task_log_model']
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
{ok, {SupFlags, Specs}}.
|
|
||||||
|
|
||||||
%%%===================================================================
|
|
||||||
%%% Internal functions
|
|
||||||
%%%===================================================================
|
|
||||||
@ -47,23 +47,14 @@ init([]) ->
|
|||||||
%},
|
%},
|
||||||
|
|
||||||
#{
|
#{
|
||||||
id => 'efka_model_sup',
|
id => cache_model,
|
||||||
start => {'efka_model_sup', start_link, []},
|
start => {cache_model, start_link, []},
|
||||||
restart => permanent,
|
restart => permanent,
|
||||||
shutdown => 2000,
|
shutdown => 5000,
|
||||||
type => supervisor,
|
type => worker,
|
||||||
modules => ['efka_model_sup']
|
modules => ['cache_model']
|
||||||
},
|
},
|
||||||
|
|
||||||
%#{
|
|
||||||
% id => 'efka_inetd_task_log',
|
|
||||||
% start => {'efka_inetd_task_log', start_link, []},
|
|
||||||
% restart => permanent,
|
|
||||||
% shutdown => 2000,
|
|
||||||
% type => worker,
|
|
||||||
% modules => ['efka_inetd_task_log']
|
|
||||||
%},
|
|
||||||
|
|
||||||
#{
|
#{
|
||||||
id => 'efka_subscription',
|
id => 'efka_subscription',
|
||||||
start => {'efka_subscription', start_link, []},
|
start => {'efka_subscription', start_link, []},
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(ws_channel).
|
-module(ws_channel).
|
||||||
-author("licheng5").
|
-author("licheng5").
|
||||||
-include("efka_service.hrl").
|
|
||||||
|
|
||||||
%% API
|
%% API
|
||||||
-export([init/2]).
|
-export([init/2]).
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user