mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
@@ -1,3 +1,10 @@
|
||||
v0.4.1 (2014-7-7)
|
||||
-----------
|
||||
* Add SERVICE_NAME in loader
|
||||
* Throw error back when skynet.error
|
||||
* Add skynet.task
|
||||
* Bugfix for last version (harbor service bugs)
|
||||
|
||||
v0.4.0 (2014-6-30)
|
||||
-----------
|
||||
* Optimize redis driver `compose_message`.
|
||||
|
||||
@@ -12,7 +12,7 @@ skynet.register_protocol {
|
||||
local w = service_map[address]
|
||||
if w then
|
||||
for watcher in pairs(w) do
|
||||
skynet.redirect(watcher, address, "error", "")
|
||||
skynet.redirect(watcher, address, "error", 0, "")
|
||||
end
|
||||
service_map[address] = false
|
||||
end
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -569,12 +576,24 @@ function skynet.monitor(service, query)
|
||||
end
|
||||
assert(monitor, "Monitor launch failed")
|
||||
c.command("MONITOR", string.format(":%08x", monitor))
|
||||
return monitor
|
||||
end
|
||||
|
||||
function skynet.mqlen()
|
||||
return tonumber(c.command "MQLEN")
|
||||
end
|
||||
|
||||
function skynet.task(ret)
|
||||
local t = 0
|
||||
for session,co in pairs(session_id_coroutine) do
|
||||
if ret then
|
||||
ret[session] = debug.traceback(co)
|
||||
end
|
||||
t = t + 1
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
-- Inject internal debug framework
|
||||
local debug = require "skynet.debug"
|
||||
debug(skynet)
|
||||
|
||||
@@ -21,9 +21,16 @@ end
|
||||
function dbgcmd.STAT()
|
||||
local stat = {}
|
||||
stat.mqlen = skynet.mqlen()
|
||||
stat.task = skynet.task()
|
||||
skynet.ret(skynet.pack(stat))
|
||||
end
|
||||
|
||||
function dbgcmd.TASK()
|
||||
local task = {}
|
||||
skynet.task(task)
|
||||
skynet.ret(skynet.pack(task))
|
||||
end
|
||||
|
||||
function dbgcmd.INFO()
|
||||
if internal_info_func then
|
||||
skynet.ret(skynet.pack(internal_info_func()))
|
||||
|
||||
@@ -262,7 +262,8 @@ harbor_release(struct harbor *h) {
|
||||
struct slave *s = &h->s[i];
|
||||
if (s->fd && s->status != STATUS_DOWN) {
|
||||
close_harbor(h,i);
|
||||
report_harbor_down(h,i);
|
||||
// don't call report_harbor_down.
|
||||
// never call skynet_send during module exit, because of dead lock
|
||||
}
|
||||
}
|
||||
hash_delete(h->map);
|
||||
@@ -509,6 +510,9 @@ remote_send_handle(struct harbor *h, uint32_t source, uint32_t destination, int
|
||||
skynet_send(context, destination, source, PTYPE_ERROR, 0 , NULL, 0);
|
||||
skynet_error(context, "Drop message to harbor %d from %x to %x (session = %d, msgsz = %d)",harbor_id, source, destination,session,(int)sz);
|
||||
} else {
|
||||
if (s->queue == NULL) {
|
||||
s->queue = new_queue();
|
||||
}
|
||||
struct remote_message_header header;
|
||||
header.source = source;
|
||||
header.destination = type << HANDLE_REMOTE_SHIFT;
|
||||
|
||||
@@ -113,6 +113,7 @@ function COMMAND.help()
|
||||
snax = "lanuch a new snax service",
|
||||
clearcache = "clear lua code cache",
|
||||
service = "List unique service",
|
||||
task = "task address : show service task detail",
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -38,6 +38,16 @@ function command.INFO(_, _, handle)
|
||||
end
|
||||
end
|
||||
|
||||
function command.TASK(_, _, handle)
|
||||
handle = handle_to_address(handle)
|
||||
if services[handle] == nil then
|
||||
return
|
||||
else
|
||||
local result = skynet.call(handle,"debug","TASK")
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
function command.KILL(_, _, handle)
|
||||
handle = handle_to_address(handle)
|
||||
skynet.kill(handle)
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user