# luaos-devel **Repository Path**: biackese/luaos-devel ## Basic Information - **Project Name**: luaos-devel - **Description**: LuaOS, 一切皆有可能 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2024-12-06 - **Last Updated**: 2025-12-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README **LuaOS for Lua5.4** - 支持单机和集群模式运行 - 支持单机和集群内 RPC 调用(同步/异步) - 支持协程 - 单进程可启动多个 Lua 微服务 - 内置 Timer 和 Socket (支持SSL和WSS) - 内置 Lua table 的共享机制, 方便配置数据的多模块共享访问 - 每个微服务由 luaos.start 函数启动运行 **加入集群范例** ``` local function main(host, port) host = host or "127.0.0.1"; port = port or 80; local ok, cluster = os.pload("luaos.cluster.adapter", host, port); if not ok then error(cluster); return; end while not os.stopped() do os.wait(); end if cluster then cluster:close(); end end luaos.start(main, ...); ``` **luaos usage** - luaos name [...] **luaos cluster** - luaos luaos.cluster.master [port] [host] **luaos http broker** - luaos luaos.http.broker [port] [host] [ca] [key] [pwd] **global functions** - bind(func, [, ...]) - trace(...) - throw(...) - wrap(...) - unwrap(str) - tostring(arg [, false | true]) - compress(str [, "deflate" | "gzip"]) - uncompress(str [, "deflate" | "gzip"]) **os functions** - os.version() - os.pload(name [, ...]) #1 - os.compile(fname [, oname]) - os.clock(["s" | "ms"]) - os.system_clock(["s" | "ms"]) - os.getcwd() - os.name([newname]) - os.hostname() - os.coroutine() #7 - os.timer() #2 - os.dirsep() - os.mkdir(name) - os.opendir([name]) - os.processors() - os.resolve([hostname]) - os.pid() - os.id() - os.post(func [, ...]) - os.poll() - os.sleep(timeout) - os.wait([expires]) - os.exit() - os.stop() - os.stopped() - os.debugging() **rpc functions** - rpc.create(name, func [, false | true]) - rpc.new([mask] [, receiver] [, timeout]) #9 - rpc.call(name [, ...]) - rpc.dispatch(name, mask, receiver [, ...]) - rpc.remove(name) - rpc.ready() - rpc.count() - rpc.provider([name]) - rpc.caller() - rpc.responser() **rpcall functions** - rpcall(name, [, callback] [, ...]) - rpcall:mask(value) - rpcall:receiver(value) - rpcall:timeout(ms) - rpcall:dispatch(name, [, ...]) **coroutine functions** - co:close(func) - co:dispatch(func) **std functions** - std.list() #3 - std.bitmap() #10 - std.skiplist([compfunc]) #8 **list functions** - list:empty() - list:size() - list:clear() - list:erase(iter) - list:front() - list:back() - list:reverse() - list:push_back(v) - list:pop_back() - list:push_front(v) - list:pop_front() **bitmap functions** - map:clear() - map:load(filename) - map:save(filename) - map:convert() - map:get() - map:set(, <0 | 1>) - map:size() - map:max_i() - map:max_x() - map:max_y() - map:min_i() - map:min_x() - map:min_y() - map:resize(width, height, fill) - map:data() - map:bits() - map:width() - map:height() **job functions** - job:close() - job:id() - job:state() **io functions** - io.context() #6 - io.socket("tcp" | "ws" [, context]) #4 - io.server("tcp" | "ws" [, context]) #5 - io.http.request_parser(options) - io.http.response_parser(options) - io.http.parse_url(url) - io.http.escape(url) - io.http.unescape(url) **socket functions** - socket:connect(host, port [, func]) - socket:close() - socket:id() - socket:read() - socket:write(data) - socket:send(data [, func]) - socket:receive(func) - socket:endpoint(["remote" | "local"]) - socket:geturi() - socket:getheader(name [, "request" | "response"]) - socket:seturi(uri) - socket:setheader(name, value) **server functions** - server:listen(host, port, func) - server:id() - server:close(); - server:endpoint() **context functions** - context:load(pemfile, keyfile [, password]) - context:period() - context:certificate(data) - context:key(data) - context:password(data) **timer functions** - timer:expires(ms, func) - timer:cancel() **math functions** - math.lucky(money, count) - math.navigate(start, finish [, depth], neighbors) - math.uuid() **string functions** - string.split(str, seq) - string.trim(str) - string.icmp(str1, str2) - string.hex(str) - string.isalpha(str) - string.isalnum(str) **table functions** - table.export(name, table) - table.import(name) **storage functions** - storage.exist(key) - storage.set(key, value [, ...]) - storage.set_if(key, func) - storage.get(key) - storage.erase(key) - storage.empty() - storage.size() - storage.clear() **json functions** - json.encode(value) - json.decode(str) **base64 functions** - base64.encode(str) - base64.decode(str) **crypto functions** - crypto.aes.encrypt(str, key) - crypto.aes.decrypt(str, key) - crypto.rsa.sign(str, key) - crypto.rsa.verify(src, sign, key) - crypto.rsa.encrypt(str, key) - crypto.rsa.decrypt(str, key) - crypto.hash32(str) - crypto.sha1(str [, false | true]) - crypto.sha224(str [, false | true]) - crypto.sha256(str [, false | true]) - crypto.sha384(str [, false | true]) - crypto.sha512(str [, false | true]) - crypto.md5(str [, false | true]) - crypto.hmac.sha1(str, key [, false | true]) - crypto.hmac.sha224(str, key [, false | true]) - crypto.hmac.sha256(str, key [, false | true]) - crypto.hmac.sha384(str, key [, false | true]) - crypto.hmac.sha512(str, key [, false | true]) - crypto.hmac.md5(str, key [, false | true]) **usage remarks** - _#01: return job object - _#02: return timer object - _#03: return list object - _#04: return socket object - _#05: return server object - _#06: return ssl context object - _#07: return coroutine object - _#08: return skiplist object - _#09: return rpcall object - _#10: return bitmap object