This commit is contained in:
anlicheng 2025-09-19 16:36:25 +08:00
parent d7e2cbf5c4
commit 1fb4cbfe61
3 changed files with 26 additions and 22 deletions

View File

@ -6,7 +6,7 @@
{applications, {applications,
[ [
sync, sync,
emqtt, % emqtt,
eredis, eredis,
ranch, ranch,
cowboy, cowboy,
@ -19,7 +19,6 @@
mysql, mysql,
gproc, gproc,
% gpb, % gpb,
esockd,
mnesia, mnesia,
crypto, crypto,
public_key, public_key,

View File

@ -53,12 +53,16 @@ start_http_server() ->
]} ]}
]), ]),
TransOpts = [ TransOpts = #{
{port, Port}, max_connections => MaxConnections,
{num_acceptors, Acceptors}, num_acceptors => Acceptors,
{backlog, Backlog}, shutdown => brutal_kill,
{max_connections, MaxConnections} socket_opts => [
], {reuseaddr, true},
{backlog, Backlog},
{port, Port}
]
},
{ok, Pid} = cowboy:start_clear(http_listener, TransOpts, #{env => #{dispatch => Dispatcher}}), {ok, Pid} = cowboy:start_clear(http_listener, TransOpts, #{env => #{dispatch => Dispatcher}}),
lager:debug("[http_server] the http server start at: ~p, pid is: ~p", [Port, Pid]). lager:debug("[http_server] the http server start at: ~p, pid is: ~p", [Port, Pid]).
@ -71,20 +75,21 @@ start_tcp_server() ->
Backlog = proplists:get_value(backlog, Props, 1024), Backlog = proplists:get_value(backlog, Props, 1024),
Port = proplists:get_value(port, Props), Port = proplists:get_value(port, Props),
TransOpts = [ TransOpts = #{
{tcp_options, [ max_connections => MaxConnections,
num_acceptors => Acceptors,
shutdown => brutal_kill,
socket_opts => [
binary, binary,
{packet, 4},
{reuseaddr, true}, {reuseaddr, true},
{active, false}, {active, false},
{packet, 4},
{nodelay, false}, {nodelay, false},
{backlog, Backlog} {backlog, Backlog},
]}, {port, Port}
{acceptors, Acceptors}, ]
{max_connections, MaxConnections} },
], {ok, _} = ranch:start_listener(tcp_server, ranch_tcp, TransOpts, tcp_channel, []),
{ok, _} = esockd:open('iot/tcp_server', Port, TransOpts, {tcp_channel, start_link, []}),
lager:debug("[iot_app] the tcp server start at: ~p", [Port]). lager:debug("[iot_app] the tcp server start at: ~p", [Port]).
-spec ensure_mnesia_schema() -> any(). -spec ensure_mnesia_schema() -> any().

View File

@ -1,15 +1,15 @@
{erl_opts, [debug_info]}. {erl_opts, [debug_info]}.
{deps, [ {deps, [
{poolboy, ".*", {git, "https://github.com/devinus/poolboy.git", {tag, "1.5.1"}}}, {poolboy, ".*", {git, "https://github.com/devinus/poolboy.git", {tag, "1.5.1"}}},
{hackney, ".*", {git, "https://github.com/benoitc/hackney.git", {tag, "1.16.0"}}}, {hackney, ".*", {git, "https://github.com/benoitc/hackney.git", {tag, "1.25.0"}}},
{sync, ".*", {git, "https://github.com/rustyio/sync.git", {branch, "master"}}}, {sync, ".*", {git, "https://github.com/rustyio/sync.git", {branch, "master"}}},
{cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {tag, "2.10.0"}}}, {cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {tag, "2.14.0"}}},
{esockd, ".*", {git, "https://github.com/emqx/esockd.git", {tag, "v5.7.3"}}}, {ranch, ".*", {git, "https://github.com/ninenines/ranch.git", {tag, "2.2.0"}}},
{brod, ".*", {git, "https://github.com/kafka4beam/brod.git", {tag, "4.4.5"}}}, {brod, ".*", {git, "https://github.com/kafka4beam/brod.git", {tag, "4.4.5"}}},
{jiffy, ".*", {git, "https://github.com/davisp/jiffy.git", {tag, "1.1.1"}}}, {jiffy, ".*", {git, "https://github.com/davisp/jiffy.git", {tag, "1.1.1"}}},
{mysql, ".*", {git, "https://github.com/mysql-otp/mysql-otp", {tag, "1.8.0"}}}, {mysql, ".*", {git, "https://github.com/mysql-otp/mysql-otp", {tag, "1.8.0"}}},
{eredis, ".*", {git, "https://github.com/wooga/eredis.git", {tag, "v1.2.0"}}}, {eredis, ".*", {git, "https://github.com/wooga/eredis.git", {tag, "v1.2.0"}}},
{emqtt, ".*", {git, "https://gitea.s5s8.com/anlicheng/emqtt.git", {branch, "main"}}}, %{emqtt, ".*", {git, "https://gitea.s5s8.com/anlicheng/emqtt.git", {branch, "main"}}},
{gproc, ".*", {git, "https://github.com/uwiger/gproc.git", {tag, "0.9.1"}}}, {gproc, ".*", {git, "https://github.com/uwiger/gproc.git", {tag, "0.9.1"}}},
{parse_trans, ".*", {git, "https://github.com/uwiger/parse_trans", {tag, "3.0.0"}}}, {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"}}} {lager, ".*", {git,"https://github.com/erlang-lager/lager.git", {tag, "3.9.2"}}}