%%% -----------------------------------------
|
|
%%% @author huangyongxing@yeah.net
|
|
%%% @doc
|
|
%%% 跨服中心节点监控树
|
|
%%% 2017-03-02
|
|
%%% @end
|
|
%%% -----------------------------------------
|
|
-module(game_center_sup).
|
|
-behaviour(supervisor).
|
|
%% API
|
|
-export([
|
|
start_link/1
|
|
,stop/0
|
|
]).
|
|
|
|
%% Supervisor callbacks
|
|
-export([init/1]).
|
|
|
|
-include("common.hrl").
|
|
-include("clusters_zone.hrl").
|
|
|
|
-define(SERVER, ?MODULE).
|
|
|
|
start_link([StrHost, StrPort | _]) ->
|
|
Host = list_to_binary(StrHost),
|
|
Port = list_to_integer(StrPort),
|
|
application:set_env(kernel, dist_auto_connect, never),
|
|
%% 程序运行日志logger管理
|
|
logger_game_h:init_log(),
|
|
%% 启动监控树
|
|
supervisor:start_link({local, ?SERVER}, ?MODULE, [Host, Port]).
|
|
|
|
%% init(Args) -> {ok, {RestartStrategy, Children}}.
|
|
%% Args : list(),
|
|
%% RestartStrategy : {one_for_one, MaxR, MaxT},
|
|
%% Children : [ChildSpec].
|
|
init([Host, Port]) ->
|
|
?INFO_TTY("Start supervisor [~w] ...", [?SERVER]),
|
|
%% {RestartStrategy, MaxR, MaxT}, MaxT秒内超过MaxR次重启,即停止监控树和子进程
|
|
RestartStrategy = {one_for_one, 50, 5},
|
|
Children = get_children([Host, Port]),
|
|
{ok, {RestartStrategy, Children}}.
|
|
|
|
%% 关服回调
|
|
%% 注意,这里的关服操作完成之后,才调用application:stop/1关闭application
|
|
stop() ->
|
|
%% TODO 跨服中的玩家踢出到所在服
|
|
ok.
|
|
|
|
get_children([_Host, Port]) ->
|
|
%% 监控树策略:{Id, StartFunc = {_, _, _}, Restart, Shutdown, Type, Modules}
|
|
ListNormalStart = [
|
|
{mod_log, start_link, []} % 日志
|
|
,{czone, start_link, []} % 标准跨服分区管理
|
|
,{svr_vitality_center_mgr, start_link, []} % 分区活跃度管理
|
|
% ,{clusters_zone, start_link, [?SMALL_ZONE_TYPE]} % 跨服服务器分区管理:小分区
|
|
% ,{clusters_zone, start_link, [?MEDIUM_ZONE_TYPE]} % 跨服服务器分区管理:中分区
|
|
% ,{clusters_zone, start_link, [?LARGE_ZONE_TYPE]} % 跨服服务器分区管理:大分区
|
|
,{mod_scene_npc, start_link,[]} % 场景npc进程
|
|
,{mod_scene_object_create, start_link, []} % 创建场景对象进程
|
|
,{scene_mgr, start_link,[]} % 场景进程池管理进程
|
|
,{online_monitor, start_link, []} % 在线资源监控、数据库心跳
|
|
,{scene_enter_queue, start_link, []} % 场景排队进入管理
|
|
,{mod_team_create, start_link, []} % 组队id进程
|
|
,{mod_drop, start_link, []} % 掉落包进程
|
|
,{mod_crontab, start_link,[]} % cron服务进程
|
|
,{timer_min, start_link,[]}
|
|
,{timer_hour, start_link,[]}
|
|
,{timer_midnight, start_link,[]}
|
|
,{timer_4_clock, start_link,[]}
|
|
,{timer_custom_kf, start_link, []}
|
|
,{mod_custom_act_kf, start_link, []} % 跨服定制活动
|
|
,{mod_global_counter, start_link, []} % 单服计数器
|
|
,{mod_top_pk_rank_center, start_link, []} % 巅峰竞技排行榜
|
|
,{mod_top_pk_match, start_link, []} % 巅峰竞技匹配
|
|
,{race_rank_act, start_link, []} % 跨服竞榜活动管理
|
|
,{race_rank_mgr, start_link, []} % 跨服竞榜排行榜进程(需要在race_rank_zone进程后面启动)
|
|
,{mod_charm_beach, start_link, []} % 魅力海滩
|
|
,{mod_cloud_buy_mgr, start_link, []} % 众仙云购
|
|
,{mod_chat_cache, start_link, []} % 聊天缓存
|
|
,{mod_3v3_center, start_link, []} % 跨服3v3
|
|
,{mod_3v3_rank, start_link, []} % 跨服3v3
|
|
,{mod_drumwar_mgr, start_link, []} % 钻石大战
|
|
,{mod_kf_1vn, start_link, []} % 跨服1vn
|
|
,{mod_kf_1vn_mgr, start_link, []} % 跨服1vn
|
|
,{mod_kf_1vn_auction, start_link, []} % 跨服1vn
|
|
,{mod_dun_multi_mgr_cluster, start_link,[]} % 跨服组队
|
|
,{mod_dungeon_agent, start_link, []} % 副本管理
|
|
,{mod_kf_supplication, start_link, []} % 祈愿
|
|
,{mod_draw_record_kf, start_link, []} % 跨服抽奖记录
|
|
,{mod_void_fam, start_link, []} % 无尽领域
|
|
,{camp_war_mgr, start_link, []} % 跨服团战
|
|
,{mod_cgwar_ctrl, start_link, []} % 跨服帮战时间管理
|
|
,{cross_guild_war_mgr, start_link, []} % 跨服帮战
|
|
,{god_dun_rank_mgr, start_link, []} % 唤神副本排行
|
|
,{madness_land, start_link,[]} % 狂战领域
|
|
,{mod_wasteland_war, start_link, []} % 废土战场(饥饿游戏)跨服管理
|
|
,{beauty_contest, start_link, []} % 靓丽大赛
|
|
,{mod_chat_zone, start_link, []} % 跨服聊天
|
|
,{seckill_center, start_link, []} % 秒杀活动
|
|
,{mod_vie_rank_center,start_link,[]} % 通用封榜
|
|
,{cross_rank_mgr, start_link, []} % 跨服排行
|
|
,{guard_dun_assist_mgr, start_link, []} % 守卫信标榜单
|
|
,{jump_act_center, start_link, []} % 跳一跳游戏
|
|
,{deserted_boss_sup, start_link, []} % 混乱星域/古战场boss/废都幻魔
|
|
,{mod_legion_mgr,start_link,[]} % 指挥室
|
|
,{mod_legion_rank_mgr,start_link,[]} % 军功榜
|
|
,{mod_military_rank_mgr,start_link,[]} % 军衔榜
|
|
,{cross_point_fight_center, start_link, []} % 沙盘争夺战-总管理系统
|
|
,{mod_pet_support_center, start_link, []} % 宠物跨服战力榜
|
|
],
|
|
ListFirstStart = [ % 其他依赖内容,最早启动
|
|
{game_env, start_link, [?SERVER]}
|
|
,{center_init, start_link, []}
|
|
,{center_svr_reg, start_link, []}
|
|
],
|
|
ListLastStart = [ % 最后启动内容
|
|
{clusters_center, start_link, []}
|
|
,{web_interface, start_link, [Port]}
|
|
,{merge, start_link, []}
|
|
,{mod_activitycalen, start_link, []} % 活动日历
|
|
],
|
|
%% 数据库连接
|
|
DbChildSpecList = db:child_spec_list(),
|
|
[
|
|
case format_child(ChildInfo) of
|
|
false -> throw(error);
|
|
Child -> Child
|
|
end || ChildInfo <- DbChildSpecList ++ ListFirstStart ++ ListNormalStart ++ ListLastStart
|
|
].
|
|
|
|
%% 将简易配置转换为supervisor的childspec格式
|
|
format_child({clusters_zone = Mod, Fun, Args}) ->
|
|
ChildName = [Mod | Args],
|
|
{ChildName, {Mod, Fun, Args}, permanent, 10000, worker, [Mod]};
|
|
format_child({Mod, Fun, Args}) ->
|
|
{Mod, {Mod, Fun, Args}, permanent, 10000, worker, [Mod]};
|
|
format_child({StartFunc = {Mod, _, _}, {child_name, ChildName}}) ->
|
|
{ChildName, StartFunc, permanent, 10000, worker, [Mod]};
|
|
format_child({StartFunc = {Mod, _, _}, Type}) ->
|
|
{Mod, StartFunc, permanent, 10000, Type, [Mod]};
|
|
format_child(Child = {_ChildName, _StartFunc = {_, _, _}, _Restart, _Shutdown, _Type, _Modules}) ->
|
|
Child;
|
|
format_child(_) ->
|
|
?ERR_TTY("监控树错误格式"),
|
|
false.
|
|
|