fix tcp server
This commit is contained in:
parent
030f15531c
commit
ebcaba4a14
@ -66,7 +66,7 @@ init([]) ->
|
|||||||
|
|
||||||
#{
|
#{
|
||||||
id => 'efka_tcp_server',
|
id => 'efka_tcp_server',
|
||||||
start => {'efka_tcp_server', start_link, [18080]},
|
start => {'efka_tcp_server', start_link, []},
|
||||||
restart => permanent,
|
restart => permanent,
|
||||||
shutdown => 2000,
|
shutdown => 2000,
|
||||||
type => worker,
|
type => worker,
|
||||||
|
|||||||
@ -10,13 +10,16 @@
|
|||||||
-author("anlicheng").
|
-author("anlicheng").
|
||||||
|
|
||||||
%% API
|
%% API
|
||||||
-export([start_link/1, init/1]).
|
-export([start_link/0, init/0]).
|
||||||
|
|
||||||
start_link(Port) ->
|
start_link() ->
|
||||||
{ok, spawn_link(?MODULE, init, [Port])}.
|
{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
|
case gen_tcp:listen(Port, [binary, {packet, 4}, {active, false}, {reuseaddr, true}]) of
|
||||||
{ok, ListenSocket} ->
|
{ok, ListenSocket} ->
|
||||||
efka_logger:debug("Server started on port ~p~n", [Port]),
|
efka_logger:debug("Server started on port ~p~n", [Port]),
|
||||||
|
|||||||
@ -2,6 +2,10 @@
|
|||||||
{efka, [
|
{efka, [
|
||||||
{root_dir, "/tmp/efka/"},
|
{root_dir, "/tmp/efka/"},
|
||||||
|
|
||||||
|
{tcp_server, [
|
||||||
|
{port, 18080}
|
||||||
|
]},
|
||||||
|
|
||||||
{tls_server, [
|
{tls_server, [
|
||||||
{host, "localhost"},
|
{host, "localhost"},
|
||||||
{port, 443}
|
{port, 443}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user