mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
41 lines
780 B
Lua
41 lines
780 B
Lua
local args = {}
|
|
for word in string.gmatch(..., "%S+") do
|
|
table.insert(args, word)
|
|
end
|
|
|
|
local main, pattern
|
|
|
|
local err = {}
|
|
for pat in string.gmatch(LUA_SERVICE, "([^;]+);*") do
|
|
local filename = string.gsub(pat, "?", args[1])
|
|
local f, msg = loadfile(filename)
|
|
if not f then
|
|
table.insert(err, msg)
|
|
else
|
|
pattern = pat
|
|
main = f
|
|
break
|
|
end
|
|
end
|
|
|
|
if not main then
|
|
error(table.concat(err, "\n"))
|
|
end
|
|
|
|
LUA_SERVICE = nil
|
|
package.path , LUA_PATH = LUA_PATH
|
|
package.cpath , LUA_CPATH = LUA_CPATH
|
|
|
|
local service_path = string.match(pattern, "(.*/)[^/?]+$")
|
|
if service_path then
|
|
package.path = service_path .. ";" .. package.path
|
|
end
|
|
|
|
if LUA_PRELOAD then
|
|
local f = assert(loadfile(LUA_PRELOAD))
|
|
f(table.unpack(args))
|
|
LUA_PRELOAD = nil
|
|
end
|
|
|
|
main(select(2, table.unpack(args)))
|