throw error when skynet.exit

This commit is contained in:
Cloud Wu
2014-07-03 17:40:07 +08:00
parent 711c04e6a9
commit f874fdc618
5 changed files with 17 additions and 3 deletions

View File

@@ -1,3 +1,8 @@
Dev version
-----------
* add SERVICE_NAME in loader
* throw error back when skynet.error
v0.4.0 (2014-6-30)
-----------
* Optimize redis driver `compose_message`.

View File

@@ -3,11 +3,13 @@ for word in string.gmatch(..., "%S+") do
table.insert(args, word)
end
SERVICE_NAME = args[1]
local main, pattern
local err = {}
for pat in string.gmatch(LUA_SERVICE, "([^;]+);*") do
local filename = string.gsub(pat, "?", args[1])
local filename = string.gsub(pat, "?", SERVICE_NAME)
local f, msg = loadfile(filename)
if not f then
table.insert(err, msg)

View File

@@ -253,6 +253,13 @@ end
function skynet.exit()
skynet.send(".launcher","lua","REMOVE",skynet.self())
for co, session in pairs(session_coroutine_id) do
local address = session_coroutine_address[co]
local self = skynet.self()
if session~=0 and address then
skynet.redirect(self, address, "error", session, "")
end
end
c.command("EXIT")
end

View File

@@ -14,7 +14,7 @@ end)
else
skynet.start(function()
local test = skynet.newservice("testdeadcall", "test") -- launch self in test mode
local test = skynet.newservice(SERVICE_NAME, "test") -- launch self in test mode
print(pcall(function()
skynet.send(test,"lua", "hello world")

View File

@@ -27,7 +27,7 @@ skynet.start(function()
local channel = mc.new()
print("New channel", channel)
for i=1,10 do
local sub = skynet.newservice("testmulticast", "sub")
local sub = skynet.newservice(SERVICE_NAME, "sub")
skynet.call(sub, "lua", "init", channel.channel)
end