-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgame_server_app.erl
More file actions
51 lines (43 loc) · 1.64 KB
/
game_server_app.erl
File metadata and controls
51 lines (43 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
%%%-----------------------------------
%%% @Module : game_server_app
%%% @Author : smyx
%%% @Created : 2013.06.30
%%% @Description: 游戏服务器应用启动
%%%-----------------------------------
-module(game_server_app).
-behaviour(application).
-export([start/2, stop/1]).
-include("common.hrl").
-include("record.hrl").
start(normal, []) ->
ping_gateway(),
ets:new(?ETS_SYSTEM_INFO, [set, public, named_table]),
ets:new(?ETS_MONITOR_PID, [set, public, named_table]),
ets:new(?ETS_STAT_SOCKET, [set, public, named_table]),
ets:new(?ETS_STAT_DB, [set, public, named_table]),
[Port, _Acceptor_num, _Max_connections] = config:get_tcp_listener(server),
[Ip] = config:get_tcp_listener_ip(server),
LogPath = config:get_log_path(server),
LogLevel = config:get_log_level(server),
Gateways = config:get_gateway_node(server),
ServerNum = config:get_server_num(),
ServerType = config:get_server_type(),
loglevel:set(tool:to_integer(LogLevel)),
io:format("LogPath:~p, loglevel: ~p~n", [LogPath, LogLevel]),
{ok, SupPid} = game_server_sup:start_link(),
game_timer:start(game_server_sup),
game_server:start(
[Ip, tool:to_integer(Port), tool:to_integer(ServerNum), tool:to_integer(ServerType), Gateways, LogPath, tool:to_integer(LogLevel)]
),
{ok, SupPid}.
stop(_State) ->
void.
ping_gateway()->
case config:get_gateway_node(server) of
undefined -> no_action;
DataList ->
Fun = fun(GatewayNode) ->
catch net_adm:ping(GatewayNode)
end ,
lists:foreach(Fun, DataList)
end.