mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 11:33:09 +00:00
@@ -1,13 +1,26 @@
|
||||
local skynet = require "skynet"
|
||||
local snax = require "snax"
|
||||
local socket = require "socket"
|
||||
|
||||
local function split_cmdline(cmdline)
|
||||
local split = {}
|
||||
for i in string.gmatch(cmdline, "%S+") do
|
||||
table.insert(split,i)
|
||||
end
|
||||
return split
|
||||
end
|
||||
|
||||
local function console_main_loop()
|
||||
local stdin = socket.stdin()
|
||||
socket.lock(stdin)
|
||||
while true do
|
||||
local cmdline = socket.readline(stdin, "\n")
|
||||
if cmdline ~= "" then
|
||||
pcall(skynet.newservice,cmdline)
|
||||
local split = split_cmdline(cmdline)
|
||||
local command = split[1]
|
||||
if command == "snax" then
|
||||
pcall(snax.newservice, select(2, table.unpack(split)))
|
||||
elseif cmdline ~= "" then
|
||||
pcall(skynet.newservice, cmdline)
|
||||
end
|
||||
end
|
||||
socket.unlock(stdin)
|
||||
|
||||
Reference in New Issue
Block a user