gate launch by watchdog

This commit is contained in:
云风
2012-08-09 19:58:23 +08:00
parent 8556d5225e
commit d3f92b32d5
6 changed files with 43 additions and 21 deletions

View File

@@ -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()

View File

@@ -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")

View File

@@ -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")