fix tcp server

This commit is contained in:
anlicheng 2025-04-18 17:38:04 +08:00
parent fadf00eb52
commit aa78ccee0a
7 changed files with 115 additions and 5 deletions

View File

@ -4,7 +4,15 @@
{registered, []}, {registered, []},
{mod, {efka_app, []}}, {mod, {efka_app, []}},
{applications, {applications,
[kernel, [
sync,
lager,
esockd,
jiffy,
gpb,
mnesia,
crypto,
kernel,
stdlib stdlib
]}, ]},
{env,[]}, {env,[]},

View File

@ -10,9 +10,37 @@
-export([start/2, stop/1]). -export([start/2, stop/1]).
start(_StartType, _StartArgs) -> start(_StartType, _StartArgs) ->
io:setopts([{encoding, unicode}]),
%% mnesia数据库
mnesia:start(),
%%
erlang:system_flag(fullsweep_after, 16),
%% tcp的服务
start_tcp_server(),
efka_sup:start_link(). efka_sup:start_link().
stop(_State) -> stop(_State) ->
ok. ok.
%% internal functions %% internal functions
%% tcp服务
start_tcp_server() ->
Port = 1883,
TransOpts = [
{tcp_options, [
binary,
{reuseaddr, true},
{active, false},
{packet, 2},
{nodelay, false},
{backlog, 1024}
]},
{acceptors, 10},
{max_connections, 1024}
],
{ok, _} = esockd:open('efka/tcp_server', Port, TransOpts, {sdlan_channel, start_link, []}),
lager:debug("[efka_app] the tcp server start at: ~p", [Port]).

View File

@ -40,3 +40,4 @@ init([]) ->
{ok, {SupFlags, ChildSpecs}}. {ok, {SupFlags, ChildSpecs}}.
%% internal functions %% internal functions

View File

@ -1,5 +1,13 @@
{erl_opts, [debug_info]}. {erl_opts, [debug_info]}.
{deps, []}. {deps, [
{hackney, ".*", {git, "https://github.com/benoitc/hackney.git", {tag, "1.17.0"}}},
{sync, ".*", {git, "https://github.com/rustyio/sync.git", {branch, "master"}}},
{esockd, ".*", {git, "https://github.com/emqx/esockd.git", {tag, "v5.8.0"}}},
{jiffy, ".*", {git, "https://github.com/davisp/jiffy.git", {tag, "1.1.2"}}},
{gpb, ".*", {git, "https://github.com/tomas-abrahamsson/gpb.git", {tag, "4.21.1"}}},
{parse_trans, ".*", {git, "https://github.com/uwiger/parse_trans", {tag, "3.0.0"}}},
{lager, ".*", {git,"https://github.com/erlang-lager/lager.git", {tag, "3.9.2"}}}
]}.
{relx, [{release, {efka, "0.1.0"}, {relx, [{release, {efka, "0.1.0"},
[efka, [efka,
@ -30,3 +38,12 @@
%% {mode, minimal} %% {mode, minimal}
] ]
}]}]}. }]}]}.
{erl_opts, [{parse_transform,lager_transform}]}.
{project_plugins, [
%% 或从 Git 仓库拉取最新版本
{pc, {git, "https://github.com/blt/port_compiler.git", {tag, "v1.15.0"}}}
]}.
{rebar_packages_cdn, "https://hexpm.upyun.com"}.

View File

@ -1 +1,57 @@
[]. {"1.2.0",
[{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.2">>},1},
{<<"esockd">>,
{git,"https://github.com/emqx/esockd.git",
{ref,"d9ce4024cc42a65e9a05001997031e743442f955"}},
0},
{<<"fs">>,{pkg,<<"fs">>,<<"6.1.1">>},1},
{<<"goldrush">>,{pkg,<<"goldrush">>,<<"0.1.9">>},1},
{<<"gpb">>,
{git,"https://github.com/tomas-abrahamsson/gpb.git",
{ref,"a53bc4909b3dc5a78b996263d92db38fed9d4782"}},
0},
{<<"hackney">>,
{git,"https://github.com/benoitc/hackney.git",
{ref,"f3e9292db22c807e73f57a8422402d6b423ddf5f"}},
0},
{<<"idna">>,{pkg,<<"idna">>,<<"6.0.1">>},1},
{<<"jiffy">>,
{git,"https://github.com/davisp/jiffy.git",
{ref,"9ea1b35b6e60ba21dfd4adbd18e7916a831fd7d4"}},
0},
{<<"lager">>,
{git,"https://github.com/erlang-lager/lager.git",
{ref,"459a3b2cdd9eadd29e5a7ce5c43932f5ccd6eb88"}},
0},
{<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},1},
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},1},
{<<"parse_trans">>,
{git,"https://github.com/uwiger/parse_trans",
{ref,"6f3645afb43c7c57d61b54ef59aecab288ce1013"}},
0},
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.6">>},1},
{<<"sync">>,
{git,"https://github.com/rustyio/sync.git",
{ref,"7dc303ed4ce8d26db82e171dbbd7c41067852c65"}},
0},
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.5.0">>},2}]}.
[
{pkg_hash,[
{<<"certifi">>, <<"B7CFEAE9D2ED395695DD8201C57A2D019C0C43ECAF8B8BCB9320B40D6662F340">>},
{<<"fs">>, <<"9D147B944D60CFA48A349F12D06C8EE71128F610C90870BDF9A6773206452ED0">>},
{<<"goldrush">>, <<"F06E5D5F1277DA5C413E84D5A2924174182FB108DABB39D5EC548B27424CD106">>},
{<<"idna">>, <<"1D038FB2E7668CE41FBF681D2C45902E52B3CB9E9C77B55334353B222C2EE50C">>},
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
{<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>},
{<<"ssl_verify_fun">>, <<"CF344F5692C82D2CD7554F5EC8FD961548D4FD09E7D22F5B62482E5AEAEBD4B0">>},
{<<"unicode_util_compat">>, <<"8516502659002CEC19E244EBD90D312183064BE95025A319A6C7E89F4BCCD65B">>}]},
{pkg_hash_ext,[
{<<"certifi">>, <<"3B3B5F36493004AC3455966991EAF6E768CE9884693D9968055AEEEB1E575040">>},
{<<"fs">>, <<"EF94E95FFE79916860649FED80AC62B04C322B0BB70F5128144C026B4D171F8B">>},
{<<"goldrush">>, <<"99CB4128CFFCB3227581E5D4D803D5413FA643F4EB96523F77D9E6937D994CEB">>},
{<<"idna">>, <<"A02C8A1C4FD601215BB0B0324C8A6986749F807CE35F25449EC9E69758708122">>},
{<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>},
{<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>},
{<<"ssl_verify_fun">>, <<"BDB0D2471F453C88FF3908E7686F86F9BE327D065CC1EC16FA4540197EA04680">>},
{<<"unicode_util_compat">>, <<"D48D002E15F5CC105A696CF2F1BBB3FC72B4B770A184D8420C8DB20DA2674B38">>}]}
].

BIN
rebar3

Binary file not shown.

4
run
View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
./rebar3 compile rebar3 compile
./rebar3 release rebar3 release
_build/default/rel/efka/bin/efka console _build/default/rel/efka/bin/efka console