$ 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 |
獲取服務內部數據 - info address
- 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)
$ 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! |
代碼熱更新 - inject address script
- if not _P then
- print "inject error!!"
- return
- end
- local command = _P.lua.command
- command.TEST = function() return "TEST" end
- print "inject ok!"
$ 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! |
使用 rlwrap 強化 skynet 控制檯
- tar -zxf rlwrap-0.37.tar.gz
- cd rlwrap-0.37
- ./configure
- make && make install
$ 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 |
Ctrl+P 上一條命令
Ctrl+N 下一條命令
Ctrl+U 從光標處刪除到行首
Ctrl+W 向前刪除一個單詞
Ctrl+B 光標向前移動一個位置
Ctrl+T 光標處字符與前一個字符交換位置
Ctrl+Z 後臺運行,使用fg調出
Ctrl+H 相當於刪除鍵
Ctrl+J 相當於回車鍵
Ctrl+O 相當於回車鍵
Ctrl+M 相當於回車鍵