fix tcp server
This commit is contained in:
parent
030f15531c
commit
ebcaba4a14
@ -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,
|
||||
|
||||
@ -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]),
|
||||
|
||||
@ -2,6 +2,10 @@
|
||||
{efka, [
|
||||
{root_dir, "/tmp/efka/"},
|
||||
|
||||
{tcp_server, [
|
||||
{port, 18080}
|
||||
]},
|
||||
|
||||
{tls_server, [
|
||||
{host, "localhost"},
|
||||
{port, 443}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user