From 0364f28599fc6cd60273a1b9107ecbf738968f87 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Fri, 16 May 2025 23:09:50 +0800 Subject: [PATCH] =?UTF-8?q?ft:=20=E5=90=AF=E5=8A=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/center.app | 34 ---------------------------------- config/cls.config | 2 +- config/gsrv.config | 2 +- config/vm.args | 5 ++++- src/center.erl | 29 ----------------------------- src/main.erl | 12 +++++++++++- start_center.sh | 2 +- start_game.sh | 2 +- 8 files changed, 19 insertions(+), 69 deletions(-) delete mode 100644 config/center.app delete mode 100644 src/center.erl diff --git a/config/center.app b/config/center.app deleted file mode 100644 index c9797de..0000000 --- a/config/center.app +++ /dev/null @@ -1,34 +0,0 @@ -%% auther: huangyongxing@yeah.net -%% date: 2016.11.09 -{ - application, - center, - [ - {description, "game server"}, - {vsn, "1.0"}, - {modules, [center]}, - {registered, []}, - {applications, [kernel, stdlib, sasl, inets, crypto, asn1, public_key, ssl]}, - {mod, {center, []}}, - {start_phases, []}, - {env, [ - {tcp_acceptor_num, 10} - ,{tcp_options, [ - binary - ,{packet, 0} - ,{active, false} - ,{keepalive, true} - ,{reuseaddr, true} - ,{nodelay, false} - ,{delay_send, true} - ,{exit_on_close, false} - ,{high_watermark, 65536} - ,{send_timeout, 15000} - ,{send_timeout_close, true} - ] - } - ,{certify, {1672502400, "5b682df2885c381e8cb434040cc3bdb1"}} - ] - } - ] -}. diff --git a/config/cls.config b/config/cls.config index 4168f87..c4d1500 100644 --- a/config/cls.config +++ b/config/cls.config @@ -16,7 +16,7 @@ {db_port, 3306}, {db_user, "root"}, {db_pass, "123456"}, - {db_name, "mrzj"}, + {db_name, "mrzj1"}, {db_encode, utf8}, {db_connections, 15}, {db_max_connections, 30}, diff --git a/config/gsrv.config b/config/gsrv.config index 77642ff..5563f90 100644 --- a/config/gsrv.config +++ b/config/gsrv.config @@ -16,7 +16,7 @@ {db_port, 3306}, {db_user, "root"}, {db_pass, "123456"}, - {db_name, "mrzj"}, + {db_name, "mrzj1"}, {db_encode, utf8}, {db_connections, 15}, {db_max_connections, 30}, diff --git a/config/vm.args b/config/vm.args index 145e899..4745894 100644 --- a/config/vm.args +++ b/config/vm.args @@ -1,6 +1,9 @@ -setcookie mrzj_dev_center +-noshell +-detached -pa ./ebin -pa ./dep/ebin -pa ./dep/ebin/debug_cmd -pa ./config -+A 64 \ No newline at end of file ++A 64 +-s main start \ No newline at end of file diff --git a/src/center.erl b/src/center.erl deleted file mode 100644 index e689f03..0000000 --- a/src/center.erl +++ /dev/null @@ -1,29 +0,0 @@ --module(center). - --behaviour(application). - --export([start/0, start/2, stop/1]). - -start() -> - AllApp = [kernel, stdlib, sasl, inets, crypto, asn1, public_key, ssl, center], - [doStartApp(App) || App <- AllApp]. - -doStartApp(MFAOrApp) -> - try - case case is_function(MFAOrApp) of true -> MFAOrApp(); _ -> application:ensure_all_started(MFAOrApp) end of - {error, AppErrReason} -> - io:format("start the app:~p error:~p", [MFAOrApp, AppErrReason]), - exit({error, AppErrReason}); - _ -> - io:format("start app ~w", [MFAOrApp]) - end - catch C:R:S -> - io:format("start the app:~p CRS:~p", [MFAOrApp, {C, R, S}]), - exit({error, {MFAOrApp, {C, R, S}}}) - end. - -start(_StartType, _StartArgs) -> - game_center_sup:start_link(["127.0.0.1", "9110"]). - -stop(_State) -> - ok. diff --git a/src/main.erl b/src/main.erl index d76e1d3..a86bbe8 100644 --- a/src/main.erl +++ b/src/main.erl @@ -2,6 +2,8 @@ -behaviour(application). +-include("clusters.hrl"). + -export([start/0, start/2, stop/1]). start() -> @@ -23,7 +25,15 @@ doStartApp(MFAOrApp) -> end. start(_StartType, _StartArgs) -> - game_master_sup:start_link(["127.0.0.1", "9310"]). + io:format("IMY*************** ~p~n", [config:get_cls_type()]), + timer:apply_after(7 *86400, init, stop, []), + case config:get_cls_type() of + ?CLUSTER_NODE -> + game_master_sup:start_link(["127.0.0.1", "9110"]); + _ -> + game_center_sup:start_link(["127.0.0.1", "9111"]) + end. + stop(_State) -> ok. diff --git a/start_center.sh b/start_center.sh index faa70a4..7daaec6 100644 --- a/start_center.sh +++ b/start_center.sh @@ -1 +1 @@ -erl -name center@127.0.0.1 -args_file "./config/vm.args" -config "./config/cls.config" -s center start \ No newline at end of file +erl -name mrzj_dev_center@127.0.0.1 -args_file "./config/vm.args" -config "./config/cls.config" \ No newline at end of file diff --git a/start_game.sh b/start_game.sh index 1decd79..4907849 100644 --- a/start_game.sh +++ b/start_game.sh @@ -1 +1 @@ -erl -name game@127.0.0.1 -args_file "./config/vm.args" -config "./config/gsrv.config" \ No newline at end of file +erl -name mrzj_dev_1@127.0.0.1 -args_file "./config/vm.args" -config "./config/gsrv.config" \ No newline at end of file