mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
gate launch by watchdog
This commit is contained in:
@@ -4,11 +4,11 @@ local client = ...
|
||||
skynet.dispatch(function(msg, sz , session, address)
|
||||
local message = skynet.tostring(msg,sz)
|
||||
if session == 0 then
|
||||
print("client command",msg)
|
||||
local result = skynet.call("SIMPLEDB",msg)
|
||||
print("client command",message)
|
||||
local result = skynet.call("SIMPLEDB",message)
|
||||
skynet.send(client, result)
|
||||
else
|
||||
print("server command",msg)
|
||||
print("server command",message)
|
||||
if msg == "CLOSE" then
|
||||
skynet.kill(client)
|
||||
skynet.exit()
|
||||
|
||||
@@ -8,10 +8,8 @@ skynet.start(function()
|
||||
print("launcher", launcher)
|
||||
local console = skynet.launch("snlua","console")
|
||||
print("console",console)
|
||||
local watchdog = skynet.launch("snlua","watchdog")
|
||||
local watchdog = skynet.launch("snlua","watchdog","8888 4 0")
|
||||
print("watchdog",watchdog)
|
||||
local gate = skynet.launch("gate","8888 4 0")
|
||||
print("gate",gate)
|
||||
local db = skynet.launch("snlua","simpledb")
|
||||
print("simpledb",db)
|
||||
local connection = skynet.launch("connection","256")
|
||||
|
||||
@@ -2,6 +2,7 @@ local skynet = require "skynet"
|
||||
|
||||
local command = {}
|
||||
local agent_all = {}
|
||||
local gate = skynet.launch("gate" , skynet.self(), ...)
|
||||
|
||||
function command:open(parm)
|
||||
local fd,addr = string.match(parm,"(%d+) ([^%s]+)")
|
||||
@@ -9,10 +10,10 @@ function command:open(parm)
|
||||
skynet.send("LOG", string.format("%d %d %s",self,fd,addr))
|
||||
local client = skynet.launch("client",fd)
|
||||
skynet.send("LOG", "client " .. client)
|
||||
local agent = skynet.launch("snlua","agent.lua",client)
|
||||
local agent = skynet.launch("snlua","agent",client)
|
||||
if agent then
|
||||
agent_all[self] = agent
|
||||
skynet.send("gate", "forward ".. self .. " " .. agent)
|
||||
skynet.send(gate, "forward ".. self .. " " .. agent)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,4 +44,4 @@ skynet.dispatch(function(msg, sz)
|
||||
end
|
||||
end)
|
||||
|
||||
skynet.register ".watchdog"
|
||||
skynet.register(".watchdog")
|
||||
|
||||
Reference in New Issue
Block a user