mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
use connection service for console
This commit is contained in:
@@ -1,12 +1,43 @@
|
||||
local skynet = require "skynet"
|
||||
local socket = require "socket"
|
||||
|
||||
local function readline(sep)
|
||||
while true do
|
||||
local line = socket.readline(sep)
|
||||
if line then
|
||||
return line
|
||||
end
|
||||
coroutine.yield()
|
||||
end
|
||||
end
|
||||
|
||||
local function split_package()
|
||||
while true do
|
||||
local cmd = readline "\n"
|
||||
if cmd ~= "" then
|
||||
local handle = skynet.launch("snlua", cmd)
|
||||
if handle == nil then
|
||||
print("Launch error:",cmd)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local split_co = coroutine.create(split_package)
|
||||
|
||||
skynet.register_protocol {
|
||||
name = "client",
|
||||
id = 3,
|
||||
pack = function(...) return ... end,
|
||||
unpack = function(msg,sz)
|
||||
assert(msg , "Stdin closed")
|
||||
socket.push(msg,sz)
|
||||
assert(coroutine.resume(split_co))
|
||||
end,
|
||||
dispatch = function () end
|
||||
}
|
||||
|
||||
|
||||
skynet.start(function()
|
||||
while true do
|
||||
local cmd = io.read()
|
||||
local handle = skynet.launch(cmd)
|
||||
if handle == nil then
|
||||
print("Launch error:",cmd)
|
||||
end
|
||||
skynet.yield()
|
||||
end
|
||||
socket.stdin()
|
||||
end)
|
||||
|
||||
@@ -3,14 +3,14 @@ local skynet = require "skynet"
|
||||
skynet.start(function()
|
||||
print("Server start")
|
||||
local launcher = skynet.launch("snlua","launcher")
|
||||
local connection = skynet.launch("connection","256")
|
||||
local lualog = skynet.launch("snlua","lualog")
|
||||
local console = skynet.launch("snlua","console")
|
||||
local group_mgr = skynet.launch("snlua", "group_mgr")
|
||||
local group_agent = skynet.launch("snlua", "group_agent")
|
||||
local remoteroot = skynet.launch("snlua","remote_root")
|
||||
local console = skynet.launch("snlua","console")
|
||||
local watchdog = skynet.launch("snlua","watchdog","8888 4 0")
|
||||
local db = skynet.launch("snlua","simpledb")
|
||||
local connection = skynet.launch("connection","256")
|
||||
local redis = skynet.launch("snlua","redis-mgr")
|
||||
-- skynet.launch("snlua","testgroup")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user