Commit c763e563a0e22fa91642841ed6619a8804e1f1fe

Authored by zhouhaihai
1 parent 6ce6fac7

删除NGX

restart.sh deleted
... ... @@ -1,17 +0,0 @@
1   -#! /bin/bash -e
2   -echo "server git pull"
3   -git pull
4   -echo "src/csvdata git pull"
5   -cd src/csvdata
6   -pwd
7   -git pull
8   -cd ../../
9   -echo "check status"
10   -port=`cat src/main.lua | grep 'services/ngxd' | sed 's/)//g' | awk '{printf $5}'`
11   -echo 'prot '$port
12   -pid=$(lsof -i:$port | grep skynet | awk '{print $2}')
13   -if [ -n "$pid" ]; then
14   - echo 'kill old server pid '$pid
15   - kill -9 $pid
16   -fi
17   -skynet/skynet src/config
18 0 \ No newline at end of file
src/actions/HttpAction.lua
... ... @@ -172,8 +172,6 @@ function _M.gm_action(query)
172 172 if isOn ~= "not_online" then
173 173 return isOn
174 174 end
175   - -- 如果_M有直接操作,跳过load角色
176   - if _M[query.cmd] then return _M[query.cmd](query) end
177 175 -- 离线操作
178 176 local role = require("models.Role").new({key = string.format("role:%d", query.id)})
179 177 local ret = role:load()
... ... @@ -184,6 +182,24 @@ function _M.gm_action(query)
184 182 return gmFuncs[query.cmd](role, query)
185 183 end
186 184  
  185 +function _M.broadcast(query)
  186 + local bin = MsgPack.pack({body = query.content})
  187 + local codes = {
  188 + ["common"] = actionCodes.Sys_commonNotice,
  189 + ["maintain"] = actionCodes.Sys_maintainNotice,
  190 + }
  191 + if not codes[query.cmd] then return "错误" end
  192 +
  193 + mcast_util.pub_world(codes[query.cmd], bin)
  194 + return "广播成功"
  195 +end
  196 +
  197 +function _M.online(query)
  198 + local count = datacenter.get("onlineCount") or 0
  199 + return count
  200 +end
  201 +
  202 +
187 203 function _M.account_init(query, body)
188 204 if not query.id or not body or body == "" then return "指令不存在" end
189 205  
... ...
src/actions/NgxAction.lua deleted
... ... @@ -1,65 +0,0 @@
1   -local string_format = string.format
2   -local mcast_util = mcast_util
3   -local gmFuncs = require "actions.GmAction"
4   -
5   -local function proc_online(cmd, roleId, pms)
6   - local agent = datacenter.get("agent", roleId)
7   - if agent then
8   - local ok, result = pcall(skynet.call, agent.serv, "lua", cmd, pms)
9   - return ok and result or "指令在线失败"
10   - end
11   - return "not_online"
12   -end
13   -
14   -local _M = {}
15   -local __const = {["id"]=1,["pm1"]=1,["pm2"]=1,["pm3"]=1}
16   -
17   -local _T = setmetatable({}, {__index = function(_, k)
18   - return function (pms)
19   - for k, v in pairs(pms) do
20   - -- tonum(v, v) 能tonumber 则 转换,不能则返回原来的值
21   - pms[k] = __const[k] and tonum(v, v) or v
22   - end
23   - -- 群体操作
24   - if not pms.id or pms.id == 0 then
25   - return _M[k] and _M[k](pms) or "指令不存在"
26   - end
27   - -- 个体操作
28   - if not gmFuncs[k] then return "指令不存在" end
29   - -- 在线操作
30   - local isOn = proc_online(k, pms.id, pms)
31   - if isOn ~= "not_online" then
32   - return isOn
33   - end
34   - -- 如果_M有直接操作,跳过load角色
35   - if _M[k] then return _M[k](pms) end
36   - -- 离线操作
37   - local role = require("models.Role").new({key = string_format("role:%d", pms.id)})
38   - local ret = role:load()
39   - if not ret then
40   - return "角色不存在"
41   - end
42   - role:loadAll()
43   - return gmFuncs[k](role, pms)
44   - end
45   -end})
46   -
47   --- 在线广播
48   -function _M.broadcast(pms)
49   - local bin = MsgPack.pack({body = pms.pm2})
50   - local codes = {
51   - ["common"] = actionCodes.Sys_commonNotice,
52   - ["maintain"] = actionCodes.Sys_maintainNotice,
53   - }
54   - if not codes[pms.pm1] then return "错误" end
55   -
56   - mcast_util.pub_world(codes[pms.pm1], bin)
57   - return "广播成功"
58   -end
59   -
60   -function _M.online(pms)
61   - local count = datacenter.get("onlineCount") or 0
62   - return count
63   -end
64   -
65   -return _T
66 0 \ No newline at end of file
src/main.lua
... ... @@ -7,14 +7,12 @@ skynet.start(function()
7 7 skynet.newservice("console")
8 8 skynet.newservice("debug_console", 10001)
9 9  
10   - local ngxd = skynet.newservice("services/ngxd", 11001)
11 10 local httpd = skynet.newservice("services/httpweb", 8001)
12 11 local watchdog = skynet.newservice("services/watchdog", max_client)
13 12  
14 13 skynet.call(watchdog, "lua", "start", {
15 14 port = 12001,
16 15 maxclient = max_client,
17   - ngxd = ngxd,
18 16 httpd = httpd,
19 17  
20 18 redishost = "127.0.0.1",
... ...
src/services/ngxd.lua deleted
... ... @@ -1,106 +0,0 @@
1   -skynet = require "skynet"
2   -redisproxy = require "shared.redisproxy"
3   -netpack = require "skynet.netpack"
4   -datacenter = require "skynet.datacenter"
5   -sharedata = require "skynet.sharedata"
6   -mcast_util = require "services/mcast_util"
7   -globalCsv = require "csvdata/GlobalDefine"
8   -
9   -local socket = require "skynet.socket"
10   -local harbor = require "skynet.harbor"
11   -
12   -require "shared.init"
13   -require "utils.init"
14   -require "ProtocolCode"
15   -require "skynet.manager"
16   -require "RedisKeys"
17   -require "GlobalVar"
18   -
19   -local port = tonumber(...)
20   -local SEP = "$end$"
21   -local actions = {}
22   -
23   -SendPacket = function(...) end
24   -rpcAgent = function(...) end
25   -rpcParter = function(...) end
26   -rpcRole = function(...) end
27   -rpcUnion = function(...) end
28   -rpcOtherUnion = function(...) end
29   -
30   -skynet.register_protocol {
31   - name = "role",
32   - id = 13,
33   - pack = skynet.pack,
34   - unpack = skynet.unpack,
35   -}
36   -
37   -local function process(request)
38   - local req = json.decode(request)
39   - if req["handle"] == "checkStatus" then
40   - return "success"
41   - end
42   -
43   - local modName, funcName = req["handle"]:match("([%w_]+)%.([%w_]+)")
44   - if not modName or not funcName then
45   - return table.concat({"handle格式错误", modName, funcName}, "\t")
46   - end
47   - local action = require("actions." .. modName .. "Action")
48   - return action[funcName](req)
49   -end
50   -
51   -local function main_loop(stdin, send)
52   - socket.lock(stdin)
53   - while true do
54   - local request = socket.readline(stdin, SEP)
55   - if not request then
56   - break
57   - end
58   -
59   - local response = process(request)
60   - if response then send(response) end
61   - end
62   - socket.unlock(stdin)
63   -end
64   -
65   -local function start()
66   - local listen_socket = socket.listen("0.0.0.0", port)
67   - print("Start nginx proxy at port: ", port)
68   -
69   - redisd = harbor.queryname("REDIS")
70   -
71   - csvdb = sharedata.query("csvdata")
72   -
73   - socket.start(listen_socket, function(id, addr)
74   - local function send(...)
75   - local t = { ... }
76   - socket.write(id, table.concat(t, "\t"))
77   - socket.write(id, SEP)
78   - end
79   - socket.start(id)
80   - skynet.fork(main_loop, id, send)
81   - end)
82   -
83   - -- 注册全服广播
84   - local channels = {}
85   - for i = 1, 10 do
86   - local channel = datacenter.get("MC_W_CHANNEL" .. i)
87   - if channel then
88   - table.insert(channels, channel)
89   - end
90   - end
91   - if #channels > 0 then
92   - mcast_util.sub_worlds(channels)
93   - end
94   -end
95   -
96   -local function __init__()
97   - skynet.dispatch("lua", function(_,_, command, ...)
98   - if command == "start" then
99   - skynet.ret(skynet.pack(start(...)))
100   - end
101   - end)
102   -
103   - skynet.register "NGXD"
104   -end
105   -
106   -skynet.start(__init__)
src/services/watchdog.lua
... ... @@ -65,14 +65,13 @@ function CMD.start(conf)
65 65 skynet.call(redisd, "lua", "open", conf)
66 66  
67 67 if use_logd == 1 then
68   - skynet.call(logd, "lua", "open", conf)
  68 + skynet.call(logd, "lua", "open")
69 69 end
70 70 -- 开启agent状态检测定时器
71 71 check_agent_status()
72 72 -- 创建广播服务
73 73 create_mutilcast()
74 74  
75   - skynet.call(conf.ngxd, "lua", "start")
76 75 skynet.call(conf.httpd, "lua", "start")
77 76  
78 77 -- roomServer = skynet.newservice("services/roomServer")
... ...