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,
[
sync,
emqtt,
% emqtt,
eredis,
ranch,
cowboy,
@ -19,7 +19,6 @@
mysql,
gproc,
% gpb,
esockd,
mnesia,
crypto,
public_key,

View File

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

View File

@ -1,15 +1,15 @@
{erl_opts, [debug_info]}.
{deps, [
{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"}}},
{cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {tag, "2.10.0"}}},
{esockd, ".*", {git, "https://github.com/emqx/esockd.git", {tag, "v5.7.3"}}},
{cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {tag, "2.14.0"}}},
{ranch, ".*", {git, "https://github.com/ninenines/ranch.git", {tag, "2.2.0"}}},
{brod, ".*", {git, "https://github.com/kafka4beam/brod.git", {tag, "4.4.5"}}},
{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"}}},
{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"}}},
{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"}}}