49 lines
1.2 KiB
Erlang
49 lines
1.2 KiB
Erlang
%%%-------------------------------------------------------------------
|
|
%% @doc efka public API
|
|
%% @end
|
|
%%%-------------------------------------------------------------------
|
|
|
|
-module(efka_app).
|
|
|
|
-behaviour(application).
|
|
|
|
-export([start/2, stop/1]).
|
|
|
|
start(_StartType, _StartArgs) ->
|
|
io:setopts([{encoding, unicode}]),
|
|
%% 启动mnesia数据库
|
|
% mnesia:start(),
|
|
%% 加速内存的回收
|
|
erlang:system_flag(fullsweep_after, 16),
|
|
|
|
%% 启动tcp的服务
|
|
start_tcp_server(),
|
|
|
|
%% 仓库的基础url
|
|
application:set_env(efka, repository_url, "http://118.178.229.213:3000/anlicheng/ekfa/"),
|
|
|
|
efka_sup:start_link().
|
|
|
|
stop(_State) ->
|
|
ok.
|
|
|
|
%% internal functions
|
|
|
|
%% 启动tcp服务
|
|
start_tcp_server() ->
|
|
Port = 1883,
|
|
TransOpts = [
|
|
{tcp_options, [
|
|
binary,
|
|
{reuseaddr, true},
|
|
{active, false},
|
|
{packet, 2},
|
|
{nodelay, false},
|
|
{backlog, 1024}
|
|
]},
|
|
{acceptors, 10},
|
|
{max_connections, 1024}
|
|
],
|
|
{ok, _} = esockd:open('efka/tcp_server', Port, TransOpts, {tcp_channel, start_link, []}),
|
|
|
|
lager:debug("[efka_app] the tcp server start at: ~p", [Port]). |