From 41d1feac8fc0813aaebba064197613aadcb53b8d Mon Sep 17 00:00:00 2001 From: xiyoo0812 Date: Sat, 7 Oct 2023 08:58:41 +0000 Subject: [PATCH] =?UTF-8?q?webhook=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96=201?= =?UTF-8?q?=E3=80=81webhook=E4=BB=85debug=E6=A8=A1=E5=BC=8F=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E5=86=85=E5=8F=91=E9=80=81HTTP=EF=BC=8C=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E6=A8=A1=E5=BC=8F=E4=BD=BF=E7=94=A8=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E9=87=87=E9=9B=86=202=E3=80=81=E5=88=A0=E9=99=A4=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=BB=A3=E7=90=86=E7=BA=BF=E7=A8=8B=203=E3=80=81web?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B8=B2=E6=9F=93=E5=8A=9F=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .luacheckrc | 26 +- bin/database.conf | 2 +- bin/share.conf | 9 +- extend/lmake/ltemplate.lua | 61 ++-- script/agent/proxy_agent.lua | 97 ------ script/basic/logger.lua | 23 +- script/constant.lua | 4 +- script/driver/webhook.lua | 62 +++- script/feature/worker.lua | 9 +- script/kernel.lua | 9 +- script/kernel/perfeval_mgr.lua | 6 +- script/network/net_client.lua | 7 +- script/network/net_server.lua | 9 +- script/network/rpc_client.lua | 5 +- script/network/rpc_server.lua | 5 +- server/center/gm_page.lua | 473 +++++++++++++++-------------- server/center/page/gm.css | 58 ++++ server/center/page/gm.html | 61 ++++ server/center/page/gm.js | 212 +++++++++++++ server/login/login_servlet.lua | 1 + server/worker/proxy.lua | 8 - server/worker/proxy/proxy_mgr.lua | 48 --- server/worker/proxy/statis_mgr.lua | 121 -------- tools/accord.bat | 12 - tools/accord/accord.lua | 145 --------- tools/accord/accord_conf.json | 1 - tools/accord/cases/login.lua | 20 -- tools/accord/server.lua | 5 - tools/gmbuild.bat | 12 + tools/mongo/index.lua | 2 +- 30 files changed, 733 insertions(+), 780 deletions(-) delete mode 100644 script/agent/proxy_agent.lua create mode 100644 server/center/page/gm.css create mode 100644 server/center/page/gm.html create mode 100644 server/center/page/gm.js delete mode 100644 server/worker/proxy.lua delete mode 100644 server/worker/proxy/proxy_mgr.lua delete mode 100644 server/worker/proxy/statis_mgr.lua delete mode 100644 tools/accord.bat delete mode 100644 tools/accord/accord.lua delete mode 100644 tools/accord/accord_conf.json delete mode 100644 tools/accord/cases/login.lua delete mode 100644 tools/accord/server.lua create mode 100644 tools/gmbuild.bat diff --git a/.luacheckrc b/.luacheckrc index 6ffdf425..56186448 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -14,24 +14,20 @@ max_cyclomatic_complexity = 13 max_code_line_length = 160 max_comment_line_length = 160 exclude_files = { - "script/luabt/*.*", - "script/luaoop/*.*", - "script/luabt/luaoop/*.*", - "script/luabt/LICENSE", - "script/luaoop/LICENSE", - "script/luabt/luaoop/LICENSE", - "server/robot/accord/page/*", - "extend/lmake/share.lua" + "extend/lmake/share.lua", + "server/robot/accord/page/*" } include_files = { - "script/*", - "server/*", - "worker/*", - "bin/proto/*.lua", - "tools/encrypt/*", - "tools/excel2lua/*", + "script/*.lua", + "server/*.lua", + "script/*/*.lua", + "server/*/*.lua", + "script/*/*/*.lua", + "server/*/*/*.lua", + "script/*/*/*/*.lua", + "server/*/*/*/*.lua", "extend/lmake/*.lua", - "extend/lmake/ltemplate/*.lua", + "tools/*/*.lua", } ignore = {"212", "213", "512"} diff --git a/bin/database.conf b/bin/database.conf index 2c7dd418..3ca8bf7f 100644 --- a/bin/database.conf +++ b/bin/database.conf @@ -19,7 +19,7 @@ set_env("QUANTA_MONGO_URLS", [[ ]]) --redis set_env("QUANTA_REDIS_URLS", [[ - redis://root:123456@127.0.0.1:6379; + redis://root:123456@10.96.8.100:6379; ]]) --mysql set_env("QUANTA_MYSQL_URLS", [[ diff --git a/bin/share.conf b/bin/share.conf index 526f5fe2..94db4188 100644 --- a/bin/share.conf +++ b/bin/share.conf @@ -137,12 +137,15 @@ set_env("QUANTA_DB_CACHE_MAX", "4096") --每帧落地最大数量 set_env("QUANTA_DB_CACHE_FLUSH", "10") ---webhook日志等级 +--webhook设置 ----------------------------------------------------- -set_env("QUANTA_WEBHOOK_LVL", "6") +--log: 日志采集 +--http:http发送 +set_env("QUANTA_WEBHOOK_MODE", "log") +--webhook地址设置 --set_env("QUANTA_LARK_URL", "https://open.feishu.cn/open-apis/bot/v2/hook/9a6565bf-51b4-48ab-80f0-64caf4d58ab8") --set_env("QUANTA_DING_URL", "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a4c64781-adad-4ddc-a615-6bc232ce71ef") ---set_env("QUANTA_WECHAT_URL", "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=ee6d97c5-477d-436f-83db-dd5361a5e8bd") +set_env("QUANTA_WECHAT_URL", "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=d7cd918c-f608-4762-87af-bb8c7fc51074") --graylog配置 ----------------------------------------------------- diff --git a/extend/lmake/ltemplate.lua b/extend/lmake/ltemplate.lua index d4082680..4a9b82ab 100644 --- a/extend/lmake/ltemplate.lua +++ b/extend/lmake/ltemplate.lua @@ -164,12 +164,11 @@ local function render(content, env) return nil, chunk end ---导出文件模板 +--根据配置导出文件模板 --tpl_f: 文件模板 --tpl_out_f: 输出文件 --tpl_env: 环境变量 ---tpl_var_f: 环境变量文件 -local function render_file(tpl_f, tpl_out_f, tpl_env, tpl_var_f) +local function render_file(tpl_f, tpl_out_f, tpl_env) if not tpl_f or not tpl_out_f or not tpl_env then error("render template file params error!") return @@ -182,19 +181,6 @@ local function render_file(tpl_f, tpl_out_f, tpl_env, tpl_var_f) tpl_env.NAME = tpl_f local content = template_file:read("*all") template_file:close() - if tpl_var_f then - setmetatable(tpl_env, { __index = function(t, k) return _G[k] end }) - local func, err = loadfile(tpl_var_f, "bt", tpl_env) - if not func then - error(sformat("open template variable file %s failed :%s", tpl_var_f, err)) - return - end - local ok, res = pcall(func) - if not ok then - error(sformat("load template variable file %s failed :%s", tpl_var_f, res)) - return - end - end local out_file = iopen(tpl_out_f, "w") if not out_file then error(sformat("open template out file %s failed!", tpl_out_f)) @@ -214,13 +200,52 @@ local function render_file(tpl_f, tpl_out_f, tpl_env, tpl_var_f) print(sformat("render template file %s to %s success!", tpl_f, tpl_out_f)) end +--输入参数 +local arg_num = select("#", ...) + --工具用法 --tpl_f: 模板文件路径 --tpl_out_f:输出文件路径 --tpl_var_f:环境变量配置文件 -if select("#", ...) == 3 then +if arg_num == 3 then + local tpl_env = {} local tpl_f, tpl_out_f, tpl_var_f = select(1, ...) - render_file(tpl_f, tpl_out_f, {}, tpl_var_f) + if tpl_var_f then + setmetatable(tpl_env, { __index = function(t, k) return _G[k] end }) + local func, err = loadfile(tpl_var_f, "bt", tpl_env) + if not func then + error(sformat("open template variable file %s failed :%s", tpl_var_f, err)) + return + end + local ok, res = pcall(func) + if not ok then + error(sformat("load template variable file %s failed :%s", tpl_var_f, res)) + return + end + end + render_file(tpl_f, tpl_out_f, tpl_env) +end + +--工具用法 +--tpl_f: 模板文件路径 +--tpl_out_f:输出文件路径 +--key:文件索引, filename:文件名, ... +if arg_num > 3 then + local tpl_env = {} + local args = { ... } + local filenum = (arg_num - 2) // 2 + for i = 1, filenum do + local key = args[2 + i * 2 - 1] + local filename = args[2 + i * 2] + local args_file = iopen(filename, "r") + if not args_file then + error(sformat("open args file %s failed!", filename)) + return + end + tpl_env[key] = args_file:read("*all") + args_file:close() + end + render_file(args[1], args[2], tpl_env) end return { diff --git a/script/agent/proxy_agent.lua b/script/agent/proxy_agent.lua deleted file mode 100644 index a6951320..00000000 --- a/script/agent/proxy_agent.lua +++ /dev/null @@ -1,97 +0,0 @@ ---proxy_agent.lua -local sformat = string.format -local tunpack = table.unpack -local send_worker = quanta.send_worker -local call_worker = quanta.call_worker - -local TITLE = quanta.title -local HOST_IP = environ.get("QUANTA_HOST_IP") - -local event_mgr = quanta.get("event_mgr") -local scheduler = quanta.load("scheduler") - -local ProxyAgent = singleton() -local prop = property(ProxyAgent) -prop:reader("ignore_statistics", {}) - -function ProxyAgent:__init() - if scheduler then - --启动代理线程 - scheduler:startup("proxy", "worker.proxy") - end - --添加忽略的rpc统计事件 - self:ignore_statis("rpc_heartbeat") - - local wlvl = environ.number("QUANTA_WEBHOOK_LVL") - if wlvl then - --添加webhook功能 - logger.add_monitor(self, wlvl) - end -end - ---dispatch_log -function ProxyAgent:dispatch_log(content, lvl_name) - self:fire_webhook(content, lvl_name) -end - ---webhook -function ProxyAgent:fire_webhook(content, lvl_name) - local title = sformat("%s | %s | %s", HOST_IP, quanta.service_name, lvl_name) - self:send("rpc_fire_webhook", title, content) -end - ---http_get -function ProxyAgent:http_get(url, querys, headers) - return self:call("rpc_http_get", url, querys, headers) -end - ---http_post -function ProxyAgent:http_post(url, post_data, headers, querys) - return self:call("rpc_http_post", url, post_data, headers, querys) -end - ---http_put -function ProxyAgent:http_put(url, put_data, headers, querys) - return self:call("rpc_http_put", url, put_data, headers, querys) -end - ---http_del -function ProxyAgent:http_del(url, querys, headers) - return self:call("rpc_http_del", url, querys, headers) -end - -function ProxyAgent:ignore_statis(name) - self.ignore_statistics[name] = true -end - -function ProxyAgent:statistics(event, name, ...) - if self.ignore_statistics[name] then - return - end - self:send(event, name, ...) -end - -function ProxyAgent:send(rpc, ...) - if scheduler then - return scheduler:send("proxy", rpc, ...) - end - if TITLE ~= "proxy" then - return send_worker("proxy", rpc, ...) - end - event_mgr:notify_listener(rpc, ...) -end - -function ProxyAgent:call(rpc, ...) - if scheduler then - return scheduler:call("proxy", rpc, ...) - end - if TITLE ~= "proxy" then - return call_worker("proxy", rpc, ...) - end - local rpc_datas = event_mgr:notify_listener(rpc, ...) - return tunpack(rpc_datas) -end - -quanta.proxy_agent = ProxyAgent() - -return ProxyAgent diff --git a/script/basic/logger.lua b/script/basic/logger.lua index a86bda04..aa461690 100644 --- a/script/basic/logger.lua +++ b/script/basic/logger.lua @@ -13,7 +13,6 @@ local LOG_LEVEL = log.LOG_LEVEL local title = quanta.title local monitors = _ENV.monitors or {} -local dispatch = false logger = {} logfeature = {} @@ -36,8 +35,8 @@ function logger.daemon(daemon) log.daemon(daemon) end -function logger.add_monitor(monitor, lvl) - monitors[monitor] = lvl +function logger.add_monitor(monitor) + monitors[monitor] = true end function logger.remove_monitor(monitor) @@ -73,7 +72,11 @@ local function logger_output(flag, feature, lvl, lvl_name, fmt, ...) lprint(LOG_LEVEL.WARN, 0, title, feature, wfmt, lvl_name, msg, info.short_src, info.linedefined) return end - return msg + if msg then + for monitor in pairs(monitors) do + monitor:dispatch_log(msg, lvl_name) + end + end end local LOG_LEVEL_OPTIONS = { @@ -84,19 +87,11 @@ local LOG_LEVEL_OPTIONS = { [LOG_LEVEL.FATAL] = { "fatal", 0x01 }, [LOG_LEVEL.DUMP] = { "dump", 0x01 | 0x02 }, } + for lvl, conf in pairs(LOG_LEVEL_OPTIONS) do local lvl_name, flag = tunpack(conf) logger[lvl_name] = function(fmt, ...) - local msg = logger_output(flag, "", lvl, lvl_name, fmt, ...) - if msg and (not dispatch) then - dispatch = true - pcall(function () - for monitor in pairs(monitors) do - monitor:dispatch_log(msg, lvl_name) - end - end) - dispatch = false - end + logger_output(flag, "", lvl, lvl_name, fmt, ...) end end diff --git a/script/constant.lua b/script/constant.lua index c91a473a..32e93a3a 100644 --- a/script/constant.lua +++ b/script/constant.lua @@ -4,8 +4,8 @@ local KernCode = enum("KernCode", 0) KernCode.SUCCESS = 0 --成功 KernCode.FAILED = 1 --系统错误,请重试 -KernCode.PARAM_ERROR = 2 --业务参数错误 -KernCode.TOO_FAST = 3 --操作太快 +KernCode.TOO_FAST = 2 --操作太快 +KernCode.PARAM_ERROR = 3 --业务参数错误 KernCode.UPHOLD = 4 --服务维护 KernCode.RPC_FAILED = 5 --RPC调用失败 KernCode.OPERATOR_SELF = 6 --不能对自己操作 diff --git a/script/driver/webhook.lua b/script/driver/webhook.lua index 400300fb..27005d05 100644 --- a/script/driver/webhook.lua +++ b/script/driver/webhook.lua @@ -1,51 +1,81 @@ --webhook.lua import("network/http_client.lua") +local jencode = json.encode local sformat = string.format -local LIMIT_COUNT = 3 -- 周期内最大次数 +local WEBPATH = environ.get("QUANTA_WEBHOOK_PATH", "./webhooks/") +local log_dump = logfeature.dump("webhooks", WEBPATH, true) +local thread_mgr = quanta.get("thread_mgr") local http_client = quanta.get("http_client") + +local HOST_IP = environ.get("QUANTA_HOST_IP") local HOUR_S = quanta.enum("PeriodTime", "HOUR_S") +local LIMIT_COUNT = 3 -- 周期内最大次数 + local Webhook = singleton() local prop = property(Webhook) +prop:reader("mode", nil) --mode +prop:reader("title", "") --title prop:reader("hooks", {}) --webhook通知接口 prop:reader("notify_limit", {}) --控制同样消息的发送频率 function Webhook:__init() - self.hooks.lark_log = environ.get("QUANTA_LARK_URL") - self.hooks.ding_log = environ.get("QUANTA_DING_URL") - self.hooks.wechat_log = environ.get("QUANTA_WECHAT_URL") + local mode = environ.get("QUANTA_WEBHOOK_MODE") + if mode then + --添加webhook功能 + self.mode = mode + logger.add_monitor(self) + self.title = sformat("%s | %s", HOST_IP, quanta.service_name) + --初始化hooks + self.hooks.lark_log = environ.get("QUANTA_LARK_URL") + self.hooks.ding_log = environ.get("QUANTA_DING_URL") + self.hooks.wechat_log = environ.get("QUANTA_WECHAT_URL") + end +end + +--hook_log +function Webhook:hook_log(url, body) + if self.mode == "log" then + log_dump(jencode(body)) + return + end + --http输出 + thread_mgr:entry(url, function() + http_client:call_post(url, body) + end) end --飞书 -function Webhook:lark_log(url, title, context) - local text = sformat("%s\n %s", title, context) +function Webhook:lark_log(url, context) + local text = sformat("%s\n %s", self.title, context) local body = { msg_type = "text", content = { text = text } } - http_client:call_post(url, body) + self:hook_log(url, body) end --企业微信 --at_members: 成员列表,数组,如 at_members = {"wangqing", "@all"} --at_mobiles: 手机号列表,数组, 如 at_mobiles = {"156xxxx8827", "@all"} -function Webhook:wechat_log(url, title, context, at_mobiles, at_members) - local text = sformat("%s\n %s", title, context) +function Webhook:wechat_log(url, context, at_mobiles, at_members) + local text = sformat("%s\n %s", self.title, context) local body = { msgtype = "text", text = { content = text, mentioned_list = at_members, mentioned_mobile_list = at_mobiles } } - http_client:call_post(url, body) + self:hook_log(url, body) end --钉钉 --at_all: 是否群at,如 at_all = false/false --at_mobiles: 手机号列表,数组, 如 at_mobiles = {"189xxxx8325", "156xxxx8827"} -function Webhook:ding_log(url, title, context, at_mobiles, at_all) - local text = sformat("%s\n %s", title, context) +function Webhook:ding_log(url, context, at_mobiles, at_all) + local text = sformat("%s\n %s", self.title, context) local body = { msgtype = "text", text = { content = text }, at = { atMobiles = at_mobiles, isAtAll = at_all } } - http_client:call_post(url, body) + self:hook_log(url, body) end -function Webhook:notify(title, content, ...) - if next(self.hooks) then +--dispatch_log +function Webhook:dispatch_log(content) + if self.mode then local now = quanta.now local notify = self.notify_limit[content] if not notify then @@ -60,7 +90,7 @@ function Webhook:notify(title, content, ...) end notify.count = notify.count + 1 for hook_api, url in pairs(self.hooks) do - self[hook_api](self, url, title, content, ...) + self[hook_api](self, url, content) end end end diff --git a/script/feature/worker.lua b/script/feature/worker.lua index b98a9661..bdb5a30d 100644 --- a/script/feature/worker.lua +++ b/script/feature/worker.lua @@ -30,6 +30,7 @@ local function init_core() import("kernel/thread_mgr.lua") import("kernel/event_mgr.lua") import("kernel/config_mgr.lua") + import("kernel/perfeval_mgr.lua") end --初始化网络 @@ -39,12 +40,6 @@ local function init_network() quanta.socket_mgr = socket_mgr end ---初始化统计 -local function init_statis() - import("agent/proxy_agent.lua") - import("kernel/perfeval_mgr.lua") -end - --协程改造 local function init_coroutine() coroutine.yield = function(...) @@ -75,6 +70,7 @@ end local function init_mainloop() import("kernel/timer_mgr.lua") import("kernel/update_mgr.lua") + import("driver/webhook.lua") event_mgr = quanta.get("event_mgr") thread_mgr = quanta.get("thread_mgr") update_mgr = quanta.get("update_mgr") @@ -88,7 +84,6 @@ function quanta.init() --主循环 init_coroutine() init_mainloop() - init_statis() --网络 init_network() --加载协议 diff --git a/script/kernel.lua b/script/kernel.lua index cc7574e1..54c358bc 100644 --- a/script/kernel.lua +++ b/script/kernel.lua @@ -24,6 +24,7 @@ local function init_core() import("kernel/thread_mgr.lua") import("kernel/event_mgr.lua") import("kernel/config_mgr.lua") + import("kernel/perfeval_mgr.lua") end --初始化网络 @@ -64,16 +65,11 @@ local function init_mainloop() import("kernel/timer_mgr.lua") import("kernel/update_mgr.lua") import("feature/scheduler.lua") + import("driver/webhook.lua") update_mgr = quanta.get("update_mgr") scheduler = quanta.get("scheduler") end ---初始化统计 -local function init_statis() - import("agent/proxy_agent.lua") - import("kernel/perfeval_mgr.lua") -end - function quanta.init() --核心加载 init_core() @@ -86,7 +82,6 @@ function quanta.init() init_coroutine() init_mainloop() init_network() - init_statis() --其他模式 if quanta.mode <= QuantaMode.ROUTER then --加载monitor diff --git a/script/kernel/perfeval_mgr.lua b/script/kernel/perfeval_mgr.lua index 475648de..81ccf98d 100644 --- a/script/kernel/perfeval_mgr.lua +++ b/script/kernel/perfeval_mgr.lua @@ -6,8 +6,6 @@ local env_status = environ.status local tclock_ms = timer.clock_ms local qdefer = quanta.defer -local proxy_agent = quanta.get("proxy_agent") - local PerfevalMgr = singleton() local prop = property(PerfevalMgr) prop:reader("eval_id", 0) @@ -75,8 +73,8 @@ function PerfevalMgr:start(eval_name) end function PerfevalMgr:stop(eval_data) - local clock_ms = tclock_ms() - proxy_agent:statistics("on_perfeval", eval_data, clock_ms) + --local clock_ms = tclock_ms() + --proxy_agent:statistics("on_perfeval", eval_data, clock_ms) self.eval_list[eval_data.co][eval_data.eval_id] = nil end diff --git a/script/network/net_client.lua b/script/network/net_client.lua index 8ae430a8..70b8ebb3 100644 --- a/script/network/net_client.lua +++ b/script/network/net_client.lua @@ -7,7 +7,6 @@ local qxpcall = quanta.xpcall local event_mgr = quanta.get("event_mgr") local socket_mgr = quanta.get("socket_mgr") local thread_mgr = quanta.get("thread_mgr") -local proxy_agent = quanta.get("proxy_agent") local proto_pb = luabus.eproto_type.pb @@ -61,7 +60,7 @@ function NetClient:connect(block) end end socket.on_call_pb = function(recv_len, session_id, cmd_id, flag, type, crc8, body) - proxy_agent:statistics("on_proto_recv", cmd_id, recv_len) + --:statistics("on_proto_recv", cmd_id, recv_len) qxpcall(self.on_socket_rpc, "on_socket_rpc: {}", self, socket, cmd_id, flag, type, session_id, body) end socket.on_error = function(token, err) @@ -116,12 +115,12 @@ function NetClient:write(cmd_id, data, type, session_id, flag) return false end -- call lbus - local send_len = self.socket.call_pb(cmd_id, flag, type, session_id, data) + local send_len = self.socket.call_pb(session_id, cmd_id, flag, type, 0, data) if send_len < 0 then log_err("[NetClient][write] call_pb failed! code:%s", send_len) return false end - proxy_agent:statistics("on_proto_send", cmd_id, send_len) + --proxy_agent:statistics("on_proto_send", cmd_id, send_len) return true end diff --git a/script/network/net_server.lua b/script/network/net_server.lua index 097f8298..3f9c50bc 100644 --- a/script/network/net_server.lua +++ b/script/network/net_server.lua @@ -14,7 +14,6 @@ local event_mgr = quanta.get("event_mgr") local thread_mgr = quanta.get("thread_mgr") local socket_mgr = quanta.get("socket_mgr") local protobuf_mgr = quanta.get("protobuf_mgr") -local proxy_agent = quanta.get("proxy_agent") local FLAG_REQ = quanta.enum("FlagMask", "REQ") local FLAG_RES = quanta.enum("FlagMask", "RES") @@ -93,7 +92,7 @@ function NetServer:on_socket_accept(session) end session.on_call_pb = function(recv_len, session_id, cmd_id, flag, type, crc8, body) local now_ms = quanta.now_ms - if session.lc_crc == crc8 and now_ms - session.lc_time < FAST_MS then + if crc8 > 0 and session.lc_crc == crc8 and now_ms - session.lc_time < FAST_MS then self:callback_errcode(session, cmd_id, TOO_FAST, session_id) return end @@ -103,7 +102,7 @@ function NetServer:on_socket_accept(session) session.fc_packet = session.fc_packet + 1 session.fc_bytes = session.fc_bytes + recv_len end - proxy_agent:statistics("on_proto_recv", cmd_id, recv_len) + --proxy_agent:statistics("on_proto_recv", cmd_id, recv_len) qxpcall(self.on_socket_recv, "on_socket_recv: {}", self, session, cmd_id, flag, type, session_id, body) end -- 绑定网络错误回调(断开) @@ -221,7 +220,7 @@ function NetServer:add_session(session) if not self.sessions[token] then self.sessions[token] = session self.session_count = self.session_count + 1 - proxy_agent:statistics("on_conn_update", self.session_type, self.session_count) + --proxy_agent:statistics("on_conn_update", self.session_type, self.session_count) end return token end @@ -232,7 +231,7 @@ function NetServer:remove_session(token) if session then self.sessions[token] = nil self.session_count = self.session_count - 1 - proxy_agent:statistics("on_conn_update", self.session_type, self.session_count) + --proxy_agent:statistics("on_conn_update", self.session_type, self.session_count) return session end end diff --git a/script/network/rpc_client.lua b/script/network/rpc_client.lua index 60a0bf73..a82d4ac8 100644 --- a/script/network/rpc_client.lua +++ b/script/network/rpc_client.lua @@ -10,7 +10,6 @@ local event_mgr = quanta.get("event_mgr") local timer_mgr = quanta.get("timer_mgr") local socket_mgr = quanta.get("socket_mgr") local thread_mgr = quanta.get("thread_mgr") -local proxy_agent = quanta.get("proxy_agent") local FLAG_REQ = quanta.enum("FlagMask", "REQ") local FLAG_RES = quanta.enum("FlagMask", "RES") @@ -59,7 +58,7 @@ end --调用rpc后续处理 function RpcClient:on_call_router(rpc, token, send_len) if send_len > 0 then - proxy_agent:statistics("on_rpc_send", rpc, send_len) + --proxy_agent:statistics("on_rpc_send", rpc, send_len) return true, send_len end log_err("[RpcClient][on_call_router] rpc {} call failed! code:{}", rpc, send_len) @@ -144,7 +143,7 @@ function RpcClient:on_socket_rpc(socket, session_id, rpc_flag, recv_len, source, if rpc == "on_heartbeat" then return end - proxy_agent:statistics("on_rpc_recv", rpc, recv_len) + --proxy_agent:statistics("on_rpc_recv", rpc, recv_len) if session_id == 0 or rpc_flag == FLAG_REQ then local function dispatch_rpc_message(...) local _ = qeval(rpc) diff --git a/script/network/rpc_server.lua b/script/network/rpc_server.lua index 82a4cdd1..8132ebc8 100644 --- a/script/network/rpc_server.lua +++ b/script/network/rpc_server.lua @@ -13,7 +13,6 @@ local hash_code = codec.hash_code local event_mgr = quanta.get("event_mgr") local thread_mgr = quanta.get("thread_mgr") local socket_mgr = quanta.get("socket_mgr") -local proxy_agent = quanta.get("proxy_agent") local FLAG_REQ = quanta.enum("FlagMask", "REQ") local FLAG_RES = quanta.enum("FlagMask", "RES") @@ -59,7 +58,7 @@ end --rpc事件 function RpcServer:on_socket_rpc(client, session_id, rpc_flag, recv_len, source, rpc, ...) - proxy_agent:statistics("on_rpc_recv", rpc, recv_len) + --proxy_agent:statistics("on_rpc_recv", rpc, recv_len) if session_id == 0 or rpc_flag == FLAG_REQ then local function dispatch_rpc_message(...) local _ = qeval(rpc) @@ -99,7 +98,7 @@ function RpcServer:on_socket_accept(client) log_err("[RpcServer][call_rpc] call failed! code:{}", send_len) return false end - proxy_agent:statistics("on_rpc_send", rpc, send_len) + --proxy_agent:statistics("on_rpc_send", rpc, send_len) return true, SUCCESS end client.on_call = function(recv_len, session_id, rpc_flag, ...) diff --git a/server/center/gm_page.lua b/server/center/gm_page.lua index 9ad5e84e..4878b737 100644 --- a/server/center/gm_page.lua +++ b/server/center/gm_page.lua @@ -12,64 +12,64 @@ return [[
@@ -81,11 +81,6 @@ return [[ - - - - -
@@ -118,179 +113,217 @@ return [[ ]] diff --git a/server/center/page/gm.css b/server/center/page/gm.css new file mode 100644 index 00000000..317d206b --- /dev/null +++ b/server/center/page/gm.css @@ -0,0 +1,58 @@ +html,body,div,h1,h2,h3,h4,h5,h6,p,span{ + padding: 0; + margin: 0; +} +body{ + padding-top: 10px; + overflow: auto; +} +.gmDumpContainer { + float: left; + border: 1px solid black; + height: 800px; + width: 30%; + margin-top:30px; + overflow: auto; +} +.gmContainer { + padding: 2px; + border: 1px solid black; + margin-top:30px; + height: 800px; + width: 70%; + overflow: auto; +} +.historyMsg{ + top: 5px; + border: 1px solid black; + height: 660px; + padding: 3px; + overflow: auto; +} +.newMsg{ + text-align: left; + margin-top: 5px; +} +.myMsg{ + background-color: grey; + color: white; + text-align: left; + margin-top: 5px; +} +.control{ + border: 1px solid black; + height: 130px; +} +.control-row{ + margin-top: 10px; +} +.inputMsg{ + height: 110px !important; + resize: none; +} +.sendBtn{ + height: 100px; +} +footer{ + text-align: center; +} \ No newline at end of file diff --git a/server/center/page/gm.html b/server/center/page/gm.html new file mode 100644 index 00000000..4e32e7a5 --- /dev/null +++ b/server/center/page/gm.html @@ -0,0 +1,61 @@ +-- luacheck: ignore +return [[ + + + + + + + + + GM Console + + + + +
+ +
+ +
+ 服务器: + + + + +
+
+
    +
  • 请选择服务器
  • +
+
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ Designed and built by quanta +
+ + + + + +]] diff --git a/server/center/page/gm.js b/server/center/page/gm.js new file mode 100644 index 00000000..34545763 --- /dev/null +++ b/server/center/page/gm.js @@ -0,0 +1,212 @@ + +function changeServer(){ + var tx = document.getElementById("curServer").value; + window.open(tx, "_self"); +} + +function onfocusServer(){ + document.getElementById("curServer").value = ""; +} + +window.onload = function(){ + var host = window.location.host ; + var selectDiv = document.getElementById("curServer"); + selectDiv.value = host + var gmconsole = new GMConsole(); + gmconsole.init(); +}; + +var GMConsole = function(){ +}; + +GMConsole.prototype = { + init: function(){ + var that = this; + var cmd_index = 0; + var historyCmds = []; + var treeNodes = [{}]; + //获取服务器列表 + var fusion_url = "http://183.66.202.114:18080/server_mgr/query"; + + // 加载命令列表 + $.ajax({ + url: "/gmlist", + type: "GET", + dataType: "json", + contentType: "utf-8", + success: function (res) { + treeNodes[0] = res; + that._showConsole(treeNodes); + }, + error: function(status) { + document.write(JSON.stringify(status)); + } + }); + + // 加载命令列表 + $.ajax({ + url: fusion_url, + type: "GET", + dataType: "json", + contentType: "utf-8", + success: function (res) { + console.log(JSON.stringify(res)); + that._showServers(res); + }, + error: function(status) { + document.write(JSON.stringify(status)); + } + }); + + //sendMsg事件 + document.getElementById('send').addEventListener('click', function(){ + that._sendCommand(historyCmds); + cmd_index = historyCmds.length + }, false); + + //inputMsg事件 + document.getElementById('inputMsg').addEventListener('keyup', function(e){ + if (e.keyCode == 13 && e.ctrlKey){ + that._sendCommand(historyCmds); + cmd_index = historyCmds.length + } else if (e.keyCode == 38){ + if (cmd_index > 0) cmd_index = cmd_index - 1 + that._showCommand(historyCmds[cmd_index]) + } else if (e.keyCode == 40){ + if (cmd_index < historyCmds.length - 1) cmd_index = cmd_index + 1 + that._showCommand(historyCmds[cmd_index]) + } + }, false); + }, + + _showCommand: function(cmd) { + var inputMsg = document.getElementById('inputMsg'); + inputMsg.value = cmd; + inputMsg.focus(); + }, + + _showConsole: function(treeNodes) { + var that = this; + $('#consoleTree').treeview({data: treeNodes}); + //consoleTree事件 + $('#consoleTree').on('nodeSelected', function(event, data) { + if (data.tag == "gm") { + //参数数组 + var arg_arr = ["
命令: ", data.text,"  参数: ", data.command];
+                if (data.example) {
+                    arg_arr.push("
示例:"); + arg_arr.push(data.example); + } + if (data.tip) { + arg_arr.push("
说明:"); + arg_arr.push(data.tip); + } + arg_arr.push("
"); + var msg = arg_arr.join("") + that._displayNewMsg("historyMsg", msg, "myMsg"); + that._showCommand(data.name + " ") + } else if (data.tag == "log") { + window.open("http://" + data.text); + } + }); + }, + + _isJson(data){ + try{ + JSON.parse(data); + } + catch(err){ + return false; + } + return true; + }, + + _showServers: function(res){ + var curServerList = document.getElementById('curServerList'); + curServerList.value = ""; + + var host = window.location.host ; + var selectDiv = document.getElementById("curServer"); + selectDiv.value = host + + for (i = 0; i < res.data.length; i++) { + var option = new Option(); + option.innerHTML = res.data[i].name; + option.value = res.data[i].web; + + curServerList.appendChild(option); + console.log(option.value) + } + }, + + _inputMsgTrim(historyCmds){ + var that = this; + var inputMsg = document.getElementById('inputMsg'); + var msg = inputMsg.value.replace('\n', ''); + if (msg == ''){ + inputMsg.focus(); + return null; + } + historyCmds.push(msg); + var result = { cmdType : "cmd", data : {} }; + that._displayNewMsg("historyMsg", msg, "myMsg"); + if(that._isJson(msg)){ + result.cmdType = "json"; + result.data = JSON.stringify({ data : JSON.parse(msg) }); + return result; + } + result.data = JSON.stringify({ data : msg }) + return result; + }, + + _sendCommand: function(historyCmds) { + var that = this; + var result = that._inputMsgTrim(historyCmds); + if(!result){ + that._displayNewMsg("historyMsg", "error", "newMsg"); + return; + } + var url = result.cmdType == "cmd" ? "/command" : "/message"; + $.ajax({ + url: url, + type: "POST", + dataType: "json", + contentType: "application/json", + data: result.data, + success: function (res) { + var result = res.msg + if (res.code != 0) { + var data = "
" + result + "
"; + that._displayNewMsg("historyMsg", data, "newMsg"); + return + } + if (typeof(result) == "object") { + var data = JSON.stringify(result, null, " "); + data = "
" + data + "
"; + that._displayNewMsg("historyMsg", data, "newMsg"); + } else { + var data = "
" + result + "
"; + that._displayNewMsg("historyMsg", data, "newMsg"); + } + }, + error: function(status) { + var data = status.responseText; + data = data.replace(new RegExp("\n",'g'),"
"); + that._displayNewMsg("historyMsg", data, "newMsg"); + } + }); + inputMsg.value = ""; + inputMsg.focus(); + }, + + _displayNewMsg: function(container_id, msg, type){ + var container = document.getElementById(container_id); + var p = document.createElement('p'); + var text = document.createElement("span"); + text.innerHTML = msg; + p.setAttribute('class', type); + p.appendChild(text); + container.appendChild(p); + container.scrollTop = container.scrollHeight; + }, +}; \ No newline at end of file diff --git a/server/login/login_servlet.lua b/server/login/login_servlet.lua index 2ca0c416..20dd236e 100644 --- a/server/login/login_servlet.lua +++ b/server/login/login_servlet.lua @@ -64,6 +64,7 @@ function LoginServlet:on_account_login_req(session, cmd_id, body, session_id) local account_params = {} if platform >= PLATFORM_PASSWORD then --登录验证 + body.ip = session.ip local result = event_mgr:notify_listener("on_platform_login", platform, open_id, access_token, body, account_params) local ok, code, sdk_open_id, sdk_device_id = tunpack(result) local login_failed, login_code = qfailed(code, ok) diff --git a/server/worker/proxy.lua b/server/worker/proxy.lua deleted file mode 100644 index 177463b7..00000000 --- a/server/worker/proxy.lua +++ /dev/null @@ -1,8 +0,0 @@ ---proxy.lua -import("feature/worker.lua") - ---启动worker -quanta.startup(function() - import("worker/proxy/proxy_mgr.lua") - import("worker/proxy/statis_mgr.lua") -end) diff --git a/server/worker/proxy/proxy_mgr.lua b/server/worker/proxy/proxy_mgr.lua deleted file mode 100644 index fbea6913..00000000 --- a/server/worker/proxy/proxy_mgr.lua +++ /dev/null @@ -1,48 +0,0 @@ ---proxy_mgr.lua -import("driver/webhook.lua") -import("driver/graylog.lua") -import("network/http_client.lua") - -local webhook = quanta.get("webhook") -local event_mgr = quanta.get("event_mgr") -local http_client = quanta.get("http_client") - -local ProxyMgr = singleton() - -function ProxyMgr:__init() - -- 注册事件 - event_mgr:add_listener(self, "rpc_fire_webhook") - -- 通用http请求 - event_mgr:add_listener(self, "rpc_http_post") - event_mgr:add_listener(self, "rpc_http_get") - event_mgr:add_listener(self, "rpc_http_put") - event_mgr:add_listener(self, "rpc_http_del") -end - ---日志上报 -function ProxyMgr:rpc_fire_webhook(title, content) - webhook:notify(title, content) -end - ---通用http请求 -function ProxyMgr:rpc_http_get(url, querys, headers) - local ok, status, res = http_client:call_get(url, querys, headers) - return ok and status or 404, res -end - -function ProxyMgr:rpc_http_post(url, post_data, headers, querys) - local ok, status, res = http_client:call_post(url, post_data, headers, querys) - return ok and status or 404, res -end - -function ProxyMgr:rpc_http_put(url, put_data, headers, querys) - local ok, status, res = http_client:call_put(url, put_data, headers, querys) - return ok and status or 404, res -end - -function ProxyMgr:rpc_http_del(url, querys, headers) - local ok, status, res = http_client:call_del(url, querys, headers) - return ok and status or 404, res -end - -quanta.proxy_mgr = ProxyMgr() diff --git a/server/worker/proxy/statis_mgr.lua b/server/worker/proxy/statis_mgr.lua deleted file mode 100644 index b063d67e..00000000 --- a/server/worker/proxy/statis_mgr.lua +++ /dev/null @@ -1,121 +0,0 @@ ---statis_mgr.lua -import("feature/worker.lua") -import("feature/linux.lua") - -local json_encode = json.encode - -local log_path = environ.get("QUANTA_STATIS_PATH") -local log_dump = logfeature.dump("statis", log_path, true) - -local event_mgr = quanta.get("event_mgr") -local update_mgr = quanta.get("update_mgr") -local linux_statis = quanta.get("linux_statis") - -local StatisMgr = singleton() -local prop = property(StatisMgr) -prop:reader("statis_datas", {}) -prop:reader("statis_enable", false) --统计开关 - -function StatisMgr:__init() - local statis_enable = environ.status("QUANTA_STATIS") - if statis_enable then - self.statis_enable = statis_enable - --定时处理 - update_mgr:attach_second5(self) - --系统监控 - if quanta.platform == "linux" then - linux_statis:setup() - end - end - --事件监听 - event_mgr:add_listener(self, "on_rpc_send") - event_mgr:add_listener(self, "on_rpc_recv") - event_mgr:add_listener(self, "on_perfeval") - event_mgr:add_listener(self, "on_proto_recv") - event_mgr:add_listener(self, "on_proto_send") - event_mgr:add_listener(self, "on_conn_update") -end - ---输出到日志 -function StatisMgr:flush() - for _, measure in pairs(self.statis_datas) do - log_dump(json_encode(measure)) - end - self.statis_datas = {} -end - -function StatisMgr:write_log(name, type, add_count) - if self.statis_enable then - self.statis_datas[#self.statis_datas + 1] = { - name = name, - type = type, - value = add_count, - index = quanta.index, - service = quanta.service, - ser_name = quanta.service_name, - } - end -end - --- 统计proto协议发送(KB) -function StatisMgr:on_proto_recv(cmd_id, send_len) - self:write_log(cmd_id, "proto_recv", send_len) -end - --- 统计proto协议接收(KB) -function StatisMgr:on_proto_send(cmd_id, recv_len) - self:write_log( cmd_id, "proto_send", recv_len) -end - --- 统计rpc协议发送(KB) -function StatisMgr:on_rpc_send(rpc, send_len) - self:write_log(rpc, "rpc_send", send_len) -end - --- 统计rpc协议接收(KB) -function StatisMgr:on_rpc_recv(rpc, recv_len) - self:write_log( rpc, "rpc_recv", recv_len) -end - --- 统计cmd协议连接 -function StatisMgr:on_conn_update(conn_type, conn_count) - self:write_log( conn_type, "conn", conn_count) -end - --- 统计性能 -function StatisMgr:on_perfeval(eval_data, clock_ms) - self:write_log(eval_data.eval_name, "perfeval", eval_data.yield_time) -end - --- 统计系统信息 -function StatisMgr:on_second5() - self:write_log("all_mem","system", self:_calc_mem_use()) - self:write_log("lua_mem","system", self:_calc_lua_mem()) - self:write_log("cpu_rate","system", self:_calc_cpu_rate()) - self:flush() -end - --- 计算lua内存信息(KB) -function StatisMgr:_calc_lua_mem() - return collectgarbage("count") -end - --- 计算内存信息(KB) -function StatisMgr:_calc_mem_use() - if quanta.platform == "linux" then - return linux_statis:calc_memory() - end - return 5000 -end - --- 计算cpu使用率 -function StatisMgr:_calc_cpu_rate() - if quanta.platform == "linux" then - return linux_statis:calc_cpu_rate() - end - return 0.1 -end - -quanta.statis_mgr = StatisMgr() - -return StatisMgr diff --git a/tools/accord.bat b/tools/accord.bat deleted file mode 100644 index b18e8b63..00000000 --- a/tools/accord.bat +++ /dev/null @@ -1,12 +0,0 @@ -@echo off - -chcp 65001 - -:: 解析xlsm文件为lua - -set LUA_PATH=!/../tools/accord/?.lua;!/../script/?.lua;; - -..\bin\quanta.exe --entry=accord --proto=../bin/proto/ --input=./accord/ --output=../server/robot/accord/ - -pause - diff --git a/tools/accord/accord.lua b/tools/accord/accord.lua deleted file mode 100644 index f864eca4..00000000 --- a/tools/accord/accord.lua +++ /dev/null @@ -1,145 +0,0 @@ ---accord.lua - -local ldir = stdfs.dir -local lstem = stdfs.stem -local lmkdir = stdfs.mkdir -local lappend = stdfs.append -local lfilename = stdfs.filename -local lextension = stdfs.extension -local lcurdir = stdfs.current_path -local serialize = luakit.serialize -local pb_enum_id = protobuf.enum -local json_encode = json.encode -local tunpack = table.unpack -local sformat = string.format -local supper = string.upper -local ogetenv = os.getenv - -local pb_indexs = {} - -local function ssplit(str, token) - local t = {} - while #str > 0 do - local pos = str:find(token) - if not pos then - t[#t + 1] = str - break - end - if pos > 1 then - t[#t + 1] = str:sub(1, pos - 1) - end - str = str:sub(pos + 1, #str) - end - return t -end - -local function sends_with(str, ending) - return str:sub(-#ending) == ending -end - -local function parse_message(full_name, proto_name) - local proto_isreq = sends_with(proto_name, "_req") - if proto_isreq then - local package_name = tunpack(ssplit(full_name, ".")) - local enum_type = package_name .. ".NCmdId" - local msg_name = "NID_" .. supper(proto_name) - local msg_id = pb_enum_id(enum_type, msg_name) - if msg_id then - local fields = {} - for name, _, typ in protobuf.fields(full_name) do - fields[name] = (typ == "string") and "xxx" or 0 - end - pb_indexs[msg_name] = { - msg_id = msg_id, - name = msg_name, - fields = fields, - } - end - end - return pb_indexs -end - ---加载pb文件 -local function load_pbfiles(proto_dir, proto_file) - local full_name = lappend(proto_dir, proto_file) - --加载PB文件 - protobuf.loadfile(full_name) - --注册CMDID和PB的映射 - for name, basename, typ in protobuf.types() do - if typ == "message" then - parse_message(name, basename) - end - end -end - ---加载pb文件 -local function load_protocol(proto_path) - local dir_files = ldir(proto_path) - for _, file in pairs(dir_files) do - if lextension(file.name) == ".pb" then - load_pbfiles(proto_path, lfilename(file.name)) - end - end -end - ---加载case文件 -local function load_cases(tool_dir, case_dir) - local tcases = {} - local case_path = lappend(tool_dir, case_dir) - local dir_files = ldir(case_path) - for _, file in pairs(dir_files or {}) do - if lextension(file.name) == ".lua" then - local name = lstem(file.name) - tcases[name] = require(sformat("%s.%s", case_dir, name)) - end - end - return tcases -end - -local function export_json(input, output) - local configs = {} - configs.accord = pb_indexs - configs.servers = require("server") - configs.cases = load_cases(input, "cases") - --export - local jdata = json_encode(configs) - local ldata = serialize(configs) - local jsonname = lappend(input, "accord_conf.json") - local json_file = io.open(jsonname, "w") - json_file:write(jdata) - json_file:close() - local confname = lappend(output, "accord_conf.lua") - local conf_file = io.open(confname, "w") - conf_file:write("--luacheck: ignore 631\n") - conf_file:write(sformat("return {\n lua = %s,\n json = [[%s]]\n}\n", ldata, jdata)) - conf_file:close() - print("export accord config success!") -end - -local proto = lcurdir() -local input = lcurdir() -local output = lcurdir() -local env_proto = ogetenv("QUANTA_PROTO") -if not env_proto or #env_proto == 0 then - print("proto dir not config!") -else - proto = lappend(proto, env_proto) -end -local env_input = ogetenv("QUANTA_INPUT") -if not env_input or #env_input == 0 then - print("input dir not config!") -else - input = lappend(input, env_input) -end -local env_output = ogetenv("QUANTA_OUTPUT") -if not env_output or #env_output == 0 then - print("output dir not config!") -else - output = lappend(output, env_output) - lmkdir(output) -end - -load_protocol(proto) -export_json(input, output) - -os.exit() diff --git a/tools/accord/accord_conf.json b/tools/accord/accord_conf.json deleted file mode 100644 index 175f322b..00000000 --- a/tools/accord/accord_conf.json +++ /dev/null @@ -1 +0,0 @@ -{"servers":["127.0.0.1:20013"],"cases":{"login":{"protocols":[{"id":10009,"name":"NID_LOGIN_ROLE_CHOOSE_REQ","args":{"role_id":0,"user_id":0}},{"id":10011,"name":"NID_LOGIN_ROLE_DELETE_REQ","args":{"role_id":0,"user_id":0}}],"name":"login","openid":"test001","password":"123456","server":"127.0.0.1:20013"}},"accord":{"NID_LOGIN_ROLE_LOGOUT_REQ":{"msg_id":10015,"name":"NID_LOGIN_ROLE_LOGOUT_REQ","fields":{"role_id":0}},"NID_LOGIN_ROLE_RELOAD_REQ":{"msg_id":10017,"name":"NID_LOGIN_ROLE_RELOAD_REQ","fields":{"role_id":0,"token":0,"lobby":0,"user_id":0}},"NID_HEARTBEAT_REQ":{"msg_id":1001,"name":"NID_HEARTBEAT_REQ","fields":{"time":0,"serial":0}},"NID_LOGIN_RANDOM_NAME_REQ":{"msg_id":10005,"name":"NID_LOGIN_RANDOM_NAME_REQ","fields":{}},"NID_LOGIN_ACCOUNT_RELOAD_REQ":{"msg_id":10003,"name":"NID_LOGIN_ACCOUNT_RELOAD_REQ","fields":{"openid":"xxx","account_token":0}},"NID_LOGIN_ROLE_CHOOSE_REQ":{"msg_id":10009,"name":"NID_LOGIN_ROLE_CHOOSE_REQ","fields":{"role_id":0,"user_id":0}},"NID_LOGIN_ROLE_CREATE_REQ":{"msg_id":10007,"name":"NID_LOGIN_ROLE_CREATE_REQ","fields":{"model":0,"gender":0,"name":"xxx","user_id":0}},"NID_LOGIN_ACCOUNT_LOGIN_REQ":{"msg_id":10001,"name":"NID_LOGIN_ACCOUNT_LOGIN_REQ","fields":{"platform":0,"openid":"xxx","session":"xxx"}},"NID_LOGIN_ROLE_LOGIN_REQ":{"msg_id":10013,"name":"NID_LOGIN_ROLE_LOGIN_REQ","fields":{"role_id":0,"token":0,"lobby":0,"user_id":0}},"NID_LOGIN_ROLE_DELETE_REQ":{"msg_id":10011,"name":"NID_LOGIN_ROLE_DELETE_REQ","fields":{"role_id":0,"user_id":0}}}} \ No newline at end of file diff --git a/tools/accord/cases/login.lua b/tools/accord/cases/login.lua deleted file mode 100644 index d716dc9e..00000000 --- a/tools/accord/cases/login.lua +++ /dev/null @@ -1,20 +0,0 @@ ---login.lua - -return { - name = "login", - openid = "test001", - password = "123456", - server = "127.0.0.1:20013", - protocols = { - { - id = 10009, - name = "NID_LOGIN_ROLE_CHOOSE_REQ", - args = { user_id = 0, role_id = 0 } - }, - { - id = 10011, - name = "NID_LOGIN_ROLE_DELETE_REQ", - args = { user_id = 0, role_id = 0 } - } - } -} \ No newline at end of file diff --git a/tools/accord/server.lua b/tools/accord/server.lua deleted file mode 100644 index 09c77a23..00000000 --- a/tools/accord/server.lua +++ /dev/null @@ -1,5 +0,0 @@ ---server.lua - -return { - "127.0.0.1:20013" -} diff --git a/tools/gmbuild.bat b/tools/gmbuild.bat new file mode 100644 index 00000000..a1169661 --- /dev/null +++ b/tools/gmbuild.bat @@ -0,0 +1,12 @@ +@echo off + +set JS=../server/center/page/gm.js +set CSS=../server/center/page/gm.css +set TPL=../server/center/page/gm.html +set OUT=../server/center/gm_page.lua +set SCRIPT=../extend/lmake/ltemplate.lua + +..\bin\lua.exe %SCRIPT% %TPL% %OUT% GM_CSS %CSS% GM_SCRIPT %JS% + +pause + diff --git a/tools/mongo/index.lua b/tools/mongo/index.lua index ef416f90..19d57e24 100644 --- a/tools/mongo/index.lua +++ b/tools/mongo/index.lua @@ -51,7 +51,7 @@ local function generate_js(input_path, ouput_path) --创建索引,默认升序 idx_file:write(sformat("db.getCollection(\"%s\").createIndex({%s: 1}, {name: \"%s\",unique: true});\n", sheet, key, key)) if key2 then - idx_file:write(sformat("db.getCollection(\"%s\").createIndex({%s: 1}, {name: \"%s\",unique: true});\n", sheet, key2, key2)) + idx_file:write(sformat("db.getCollection(\"%s\").createIndex({%s: 1}, {name: \"%s\",unique: true});\n", sheet, key2, key2)) end idx_file:write("//------------------------------------------------------------------------\n\n") end