$ nc 127.0.0.1 8000
Welcome to skynet console
help
clearcache clear lua code cache
cmem Show C memory info
debug debug address : debug a lua service
exit exit address : kill a lua service
gc gc : force every lua service do garbage collect
help This help message
info Info address : get service infomation
inject inject address luascript.lua
kill kill address : kill service
list List all the service
logoff logoff address
logon logon address
mem mem : show memory status
service List unique service
signal signal address sig
snax lanuch a new snax service
start lanuch a new lua service
stat Dump all stats
task task address : show service task detail
|
local skynet = require "skynet" require "skynet.manager" -- import skynet.register local db = {} local command = {} function command.GET(key) return db[key] end function command.SET(key, value) local last = db[key] db[key] = value return last end -- 新增的代码 -- start skynet.info_func(function() return "hello mycwq!" end) -- 新增的代码 -- end skynet.start(function() skynet.dispatch("lua", function(session, address, cmd, ...) local f = command[string.upper(cmd)] if f then skynet.ret(skynet.pack(f(...))) else error(string.format("Unknown command %s", tostring(cmd))) end end) skynet.register "SIMPLEDB" end)启动example例子, 连接控制台,
$ nc 127.0.0.1 8000
Welcome to skynet console
list
:00000004 snlua cmaster
:00000005 snlua cslave
:00000007 snlua datacenterd
:00000008 snlua service_mgr
:0000000a snlua protoloader
:0000000b snlua console
:0000000c snlua debug_console 8000
:0000000d snlua simpledb
:0000000e snlua watchdog
:0000000f snlua gate
OK
info :0000000d
hello mycwq!
|
if not _P then print "inject error!!" return end local command = _P.lua.command command.TEST = function() return "TEST" end print "inject ok!"启动example例子, 连接控制台,
$ nc 127.0.0.1 8000
Welcome to skynet console
list
:00000004 snlua cmaster
:00000005 snlua cslave
:00000007 snlua datacenterd
:00000008 snlua service_mgr
:0000000a snlua protoloader
:0000000b snlua console
:0000000c snlua debug_console 8000
:0000000d snlua simpledb
:0000000e snlua watchdog
:0000000f snlua gate
OK
inject
:0000000d example/inject_simpledb.lua
inject ok!
|
yum -y install readline-develrlwrap则需要手动安装,这里附 rlwrap下载地址, 点这里。 安装 rlwrap很简单,如下:
tar -zxf rlwrap-0.37.tar.gz cd rlwrap-0.37 ./configure make && make install以后,skynet控制台的连接方式改成这样,就可以回溯命令了。
$ rlwrap nc 127.0.0.1 8000
Welcome to skynet console
list
:01000004 snlua cmaster
:01000005 snlua cslave
:01000007 snlua datacenterd
:01000008 snlua service_mgr
:0100000a snlua protoloader
:0100000b snlua console
:0100000c snlua debug_console 8000
:0100000d snlua simpledb
:0100000e snlua watchdog
:0100000f snlua gate
OK
|