fix tcp server

This commit is contained in:
anlicheng 2025-05-09 21:30:57 +08:00
parent 030f15531c
commit ebcaba4a14
3 changed files with 12 additions and 5 deletions

View File

@ -66,7 +66,7 @@ init([]) ->
#{
id => 'efka_tcp_server',
start => {'efka_tcp_server', start_link, [18080]},
start => {'efka_tcp_server', start_link, []},
restart => permanent,
shutdown => 2000,
type => worker,

View File

@ -10,13 +10,16 @@
-author("anlicheng").
%% API
-export([start_link/1, init/1]).
-export([start_link/0, init/0]).
start_link(Port) ->
{ok, spawn_link(?MODULE, init, [Port])}.
start_link() ->
{ok, spawn_link(?MODULE, init, [])}.
%%
init(Port) ->
init() ->
{ok, TcpServerProps} = application:get_env(efka, tcp_server),
Port = proplists:get_value(port, TcpServerProps),
case gen_tcp:listen(Port, [binary, {packet, 4}, {active, false}, {reuseaddr, true}]) of
{ok, ListenSocket} ->
efka_logger:debug("Server started on port ~p~n", [Port]),

View File

@ -2,6 +2,10 @@
{efka, [
{root_dir, "/tmp/efka/"},
{tcp_server, [
{port, 18080}
]},
{tls_server, [
{host, "localhost"},
{port, 443}