huahua132 / skynet_fly Goto Github PK
View Code? Open in Web Editor NEW基于云风的skynet,搭建开箱即用的微服务框架,提供优雅的服务热更新
Home Page: https://huahua132.github.io/2023/02/25/skynet_fly_word/word_1/A_home/
License: MIT License
基于云风的skynet,搭建开箱即用的微服务框架,提供优雅的服务热更新
Home Page: https://huahua132.github.io/2023/02/25/skynet_fly_word/word_1/A_home/
License: MIT License
如果想多台机器部署做分布式 这个支持吗
Hihi,
我们使用了你的skynet_fly框架开发一个简单游戏,作为小游戏上线到telegram app。
比较奇怪的是,在某些PC和IOS,Android平台下是可以运行的,但是部分在websocket握手完以后,出现了发包错误。
在尚不清楚在什么情况下,某些机器的某些平台突然就可以了,而某些机器和某些平台又突然不可以了。
可以明确的是,该机器在没有经过telegram打包情况下是可以连通的。
分析在不可运行的机器发送过来的服务器侧消息,websocket握手完,第一个包的opcode是text。而原则上我们的包都应该是binary,长度也不太对(84vs110)。
不知道你有没有什么想法或者修改方式
Hi @huahua132 . The lua-radix-router is optimized for high performance. Compared to the current router(based on redis rax), the lua-radix-router is 70x faster in real-world use cases. It is possible to switch lua-radix-router? I think the APIs are basically the same, it should be easy to replace without introducing any breaking changes.
人比较菜,想边学习边搭建个小网站练手,目前遇到的报错如下:
如果单个创建的有冲突就报错了
local ret = client:create_one_entry({player_id = 10005})
[:0000000f][20240630 16:32:42 76]lua call [e to :f : 40 msgsz = 94] error : �[31m../../skynet/lualib/skynet.lua:987: ../../skynet/lualib/skynet.lua:452: ../../skynet/lualib/skynet/queue.lua:20: ../../skynet/lualib/skynet/queue.lua:20: ../../lualib/skynet-fly/db/ormadapter/ormadapter_mysql.lua:375: _insert_one err insert into t_player (player_id
,nickname
,sex
,status
) value(10005,0,0,0)
stack traceback:
[C]: in function 'error'
../../lualib/skynet-fly/db/ormadapter/ormadapter_mysql.lua:375: in function <../../lualib/skynet-fly/db/ormadapter/ormadapter_mysql.lua:369>
(...tail calls...)
../../lualib/skynet-fly/db/orm/ormtable.lua:593: in function <../../lualib/skynet-fly/db/orm/ormtable.lua:588>
[C]: in function 'xpcall'
../../skynet/lualib/skynet/queue.lua:34: in function <../../skynet/lualib/skynet/queue.lua:24>
(...tail calls...)
../../module/orm_table_m.lua:34: in function <../../module/orm_table_m.lua:33>
[C]: in function 'xpcall'
../../skynet/lualib/skynet/queue.lua:34: in upvalue 'queue'
../../module/orm_table_m.lua:173: in function 'orm_table_m.call'
../../lualib/skynet-fly/utils/skynet_util.lua:39: in upvalue 'f'
../../skynet/lualib/skynet.lua:402: in function <../../skynet/lualib/skynet.lua:374>
stack traceback:
[C]: in function 'assert'
../../skynet/lualib/skynet/queue.lua:20: in function <../../skynet/lualib/skynet/queue.lua:12>
(...tail calls...)
../../module/orm_table_m.lua:34: in function <../../module/orm_table_m.lua:33>
[C]: in function 'xpcall'
../../skynet/lualib/skynet/queue.lua:34: in upvalue 'queue'
../../module/orm_table_m.lua:173: in function 'orm_table_m.call'
../../lualib/skynet-fly/utils/skynet_util.lua:39: in upvalue 'f'
../../skynet/lualib/skynet.lua:402: in function <../../skynet/lualib/skynet.lua:374>
stack traceback:
[C]: in function 'assert'
../../skynet/lualib/skynet/queue.lua:20: in function <../../skynet/lualib/skynet/queue.lua:12>
(...tail calls...)
../../module/orm_table_m.lua:173: in function 'orm_table_m.call'
../../lualib/skynet-fly/utils/skynet_util.lua:39: in upvalue 'f'
../../skynet/lualib/skynet.lua:402: in function <../../skynet/lualib/skynet.lua:374>
stack traceback:
[C]: in function 'assert'
../../skynet/lualib/skynet.lua:987: in function 'skynet.dispatch_message'�[0m
[:00000010][20240630 16:32:42 76]lua call [f to :10 : 24 msgsz = 0] error : �[31m../../skynet/lualib/skynet.lua:987: ../../skynet/lualib/skynet.lua:452: ../../skynet/lualib/skynet.lua:719: call failed
stack traceback:
[C]: in function 'error'
../../skynet/lualib/skynet.lua:719: in upvalue 'yield_call'
../../skynet/lualib/skynet.lua:736: in function 'skynet.call'
(...tail calls...)
../../lualib/skynet-fly/client/orm_table_client.lua:21: in method 'create_one_entry'
./module/test_m.lua:34: in upvalue 'f'
../../skynet/lualib/skynet.lua:375: in function <../../skynet/lualib/skynet.lua:374>
stack traceback:
[C]: in function 'assert'
../../skynet/lualib/skynet.lua:987: in function 'skynet.dispatch_message'�[0m
我想在第一个玩家进入后只创建一个桌子,之后所有玩家都进去这个桌子,于是我这么写
enter = function(player_id)
if not m_player_list[player_id] then
log.info("进入房间成功 ", player_id)
m_player_list[player_id] = player:new()
m_player_list[player_id]:init(player_id)
if m_finish_init ~= true then
m_finish_init = true
timer:new(timer.second * 3, 1, function()
skynet.fork(game_start)
end)
end
else
log.info("断线重连 ", player_id)
end
return 0
end,
但是热更失效了,代码和配置都无法热更新。我这种写法有问题吗?
Cannot build on both Intel and Apple CPU on MacOSX
make build
cc -g -O0 -Wall -Iskynet/3rd/lua -I3rd/lua-openssl-0.8.5-0/deps/auxiliar/ -I3rd/lua-openssl-0.8.5-0/deps/lua-compat/ -I3rd/lua-openssl-0.8.5-0/deps/lua-compat/c-api/ -I3rd/lua-openssl-0.8.5-0/src/ -fPIC --shared -I3rd/luafilesystem-1_8_0/src 3rd/luafilesystem-1_8_0/src/lfs.c -o luaclib/lfs.so
ld: Undefined symbols:
_luaL_argerror, referenced from:
_dir_iter in lfs-c038af.o
_luaL_checklstring, referenced from:
_change_dir in lfs-c038af.o
_dir_iter_factory in lfs-c038af.o
_make_link in lfs-c038af.o
_make_link in lfs-c038af.o
_file_lock in lfs-c038af.o
_make_dir in lfs-c038af.o
_remove_dir in lfs-c038af.o
...
_luaL_checkoption, referenced from:
_lfs_g_setmode in lfs-c038af.o
_luaL_checkudata, referenced from:
_dir_iter in lfs-c038af.o
_lfs_unlock_dir in lfs-c038af.o
_check_file in lfs-c038af.o
_luaL_checkversion_, referenced from:
_luaopen_lfs in lfs-c038af.o
_luaL_error, referenced from:
_dir_iter_factory in lfs-c038af.o
__file_info_ in lfs-c038af.o
_check_file in lfs-c038af.o
__file_lock in lfs-c038af.o
_luaL_newmetatable, referenced from:
_dir_create_meta in lfs-c038af.o
_lock_create_meta in lfs-c038af.o
_luaL_optinteger, referenced from:
_file_lock in lfs-c038af.o
_file_lock in lfs-c038af.o
_file_utime in lfs-c038af.o
_file_unlock in lfs-c038af.o
_file_unlock in lfs-c038af.o
_luaL_optnumber, referenced from:
_file_utime in lfs-c038af.o
_luaL_setfuncs, referenced from:
_luaopen_lfs in lfs-c038af.o
_lua_createtable, referenced from:
_luaopen_lfs in lfs-c038af.o
_dir_create_meta in lfs-c038af.o
_lock_create_meta in lfs-c038af.o
__file_info_ in lfs-c038af.o
_lua_getfield, referenced from:
_dir_iter_factory in lfs-c038af.o
_lfs_lock_dir in lfs-c038af.o
_lua_gettop, referenced from:
_file_utime in lfs-c038af.o
_lua_isstring, referenced from:
_link_info in lfs-c038af.o
__file_info_ in lfs-c038af.o
_lua_newuserdatauv, referenced from:
_dir_iter_factory in lfs-c038af.o
_lfs_lock_dir in lfs-c038af.o
_lua_pushboolean, referenced from:
_change_dir in lfs-c038af.o
_file_lock in lfs-c038af.o
_file_unlock in lfs-c038af.o
_pushresult in lfs-c038af.o
_lfs_g_setmode in lfs-c038af.o
_lua_pushcclosure, referenced from:
_dir_create_meta in lfs-c038af.o
_dir_create_meta in lfs-c038af.o
_dir_create_meta in lfs-c038af.o
_dir_create_meta in lfs-c038af.o
_lock_create_meta in lfs-c038af.o
_lock_create_meta in lfs-c038af.o
_dir_iter_factory in lfs-c038af.o
...
_lua_pushfstring, referenced from:
_change_dir in lfs-c038af.o
_file_lock in lfs-c038af.o
_file_unlock in lfs-c038af.o
__file_info_ in lfs-c038af.o
_pusherror in lfs-c038af.o
_lua_pushinteger, referenced from:
_push_st_dev in lfs-c038af.o
_push_st_ino in lfs-c038af.o
_push_st_nlink in lfs-c038af.o
_push_st_uid in lfs-c038af.o
_push_st_gid in lfs-c038af.o
_push_st_rdev in lfs-c038af.o
_push_st_atime in lfs-c038af.o
...
_lua_pushlstring, referenced from:
_push_link_target in lfs-c038af.o
_lua_pushnil, referenced from:
_change_dir in lfs-c038af.o
_dir_iter_factory in lfs-c038af.o
_file_lock in lfs-c038af.o
_file_unlock in lfs-c038af.o
_lfs_lock_dir in lfs-c038af.o
_lfs_lock_dir in lfs-c038af.o
__file_info_ in lfs-c038af.o
...
_lua_pushstring, referenced from:
_push_st_mode in lfs-c038af.o
_push_st_perm in lfs-c038af.o
_set_info in lfs-c038af.o
_set_info in lfs-c038af.o
_set_info in lfs-c038af.o
_dir_iter in lfs-c038af.o
_get_dir in lfs-c038af.o
...
_lua_pushvalue, referenced from:
_luaopen_lfs in lfs-c038af.o
_dir_iter_factory in lfs-c038af.o
_lua_rawset, referenced from:
__file_info_ in lfs-c038af.o
_lua_setfield, referenced from:
_dir_create_meta in lfs-c038af.o
_dir_create_meta in lfs-c038af.o
_dir_create_meta in lfs-c038af.o
_dir_create_meta in lfs-c038af.o
_dir_create_meta in lfs-c038af.o
_lock_create_meta in lfs-c038af.o
_lock_create_meta in lfs-c038af.o
_lock_create_meta in lfs-c038af.o
...
_lua_setglobal, referenced from:
_luaopen_lfs in lfs-c038af.o
_lua_setmetatable, referenced from:
_dir_iter_factory in lfs-c038af.o
_lfs_lock_dir in lfs-c038af.o
_lua_settop, referenced from:
__file_info_ in lfs-c038af.o
_lua_toboolean, referenced from:
_make_link in lfs-c038af.o
_lua_tolstring, referenced from:
_link_info in lfs-c038af.o
__file_info_ in lfs-c038af.o
_lua_touserdata, referenced from:
_dir_close in lfs-c038af.o
_lua_type, referenced from:
_link_info in lfs-c038af.o
__file_info_ in lfs-c038af.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [luaclib/lfs.so] Error 1
比如客户端的通用的protobuffer格式如下:
message RequestMessage{
int32 cmdCode = 1;
int32 cmdMerge = 2;
sint32 status = 3; //固定0
bytes data = 4;
}
具体某个业务协议如下:
message playgameReq{
int32 playerid = 1;
int32 type=2;
}
客户端首先将业务协议用protoc打包成data,放入到通用格式的最后一个字段。然后再对通用格式又一次进行protoc打包,最后发送。
那底层这边的pb_netpack.lua是否要这么改:
function M.encode(name, cmdCode, cmdMerge, status, tab)
assert(name)
assert(tab)
if not g_loaded[name] then
return nil, "encode not exists " .. name
end
local ok, str = x_pcall(pb.encode,name, tab)
pack_msg={
cmdCode=1000,
cmdmerge = 0,
data = str,
}
return x_pcall(pb.encode,"RequestMessage", msg)
end
function M.create_pack(encode)
return function(name,tab)
assert(name)
assert(tab)
local ok,str = encode(name,tab)
if not ok then
return nil,str
end
local pbmsgbuff = spack(">I2",name:len()) .. name .. str
return pbmsgbuff
end
end
打包json消息的时候也要传入packname吗?
之前在腾讯云上传启动没问题,今天换了一台阿里云的机器就报这样的错误了,环境搭建都是一样的步骤,这是为啥啊
[:0000000d][20231128 13:26:21 23][fatal][contriner_mgr][../../skynet_fly/service/contriner_mgr.lua:81]launch_new_module err room_game_hall_m {
net_util = ws_pbnet_util,
hall_plug = hall_plug,
}[:00000011][20231128 13:26:21 23]LAUNCH snlua hot_container room_game_alloc_m 1 2023-11-28[13:26:21] 1701149181 1
[:00000010][20231128 13:26:21 23]lua call [d to :10 : 6 msgsz = 51] error : ^[[31m../../skynet_fly/skynet/lualib/skynet.lua:966: ../../skynet_fly/skynet/lualib/skynet.lua:434: ../../skynet_fly/skynet/lualib/skynet/require.lua:96: ../../skynet_fly/skynet/lualib/skynet/require.lua:96: ../../skynet_fly/skynet/lualib/skynet/require.lua:96: ../../skynet_fly/skynet/lualib/skynet/require.lua:96: ../../skynet_fly/skynet/lualib/skynet.lua:53: assertion failed!
stack traceback:
[C]: in function 'assert'
../../skynet_fly/skynet/lualib/skynet.lua:53: in function 'skynet.register_protocol'
../../skynet_fly/skynet/lualib/skynet/socket.lua:201: in upvalue 'modfunc'
../../skynet_fly/skynet/lualib/skynet/require.lua:67: in function <../../skynet_fly/skynet/lualib/skynet/require.lua:66>
[C]: in function 'xpcall'
../../skynet_fly/skynet/lualib/skynet/require.lua:80: in function 'skynet.require.require'
(...tail calls...)
../../skynet_fly/lualib/utils/net/util_net_base.lua:2: in upvalue 'modfunc'
../../skynet_fly/skynet/lualib/skynet/require.lua:67: in function <../../skynet_fly/skynet/lualib/skynet/require.lua:66>
[C]: in function 'xpcall'
../../skynet_fly/skynet/lualib/skynet/require.lua:80: in function 'skynet.require.require'
(...tail calls...)
../../skynet_fly/lualib/utils/net/ws_pbnet_util.lua:3: in upvalue 'modfunc'
../../skynet_fly/skynet/lualib/skynet/require.lua:67: in function <../../skynet_fly/s
这里我使用的是json封包解包
skynet_fly_demo\skynet_fly\lualib\utils\net\util_net_base.lua:
local msg, err = pack(name, tab)
if not msg then
log.error("pb_netpack.pack err ", name, tab, err)
return
end
--大端2字节表示包长度
local send_buffer = string.pack(">I2", msg:len()) .. msg
log.info("send name:", name)
log.info("send msg:", tostring(msg))
那我对应的测试客户端可以直接用json.unpack解出来吗
还是必须要按这个pack的逆向过程处理一遍
在table_plug.lua中写入:
local redisf = require "redisf"
执行到skynet_fly_demo\skynet_fly\lualib\write_mod_required.lua这里会报错,无法生成module_info\room_game_table_m.required:
[:00000012][20231121 17:59:51 58]lua call [d to :12 : 11 msgsz = 72] error : ^[[31m../../skynet_fly/skynet/lualib/skynet.lua:966: ../../skynet_fly/skynet/lualib/skynet.lua:434: ../../skynet_fly/skynet/lualib/skynet/require.lua:96: ../../skynet_fly/skynet/lualib/skynet/require.lua:96: ../../skynet_fly/skynet/lualib/skynet/require.lua:36: module 'sha2' not found:
no field package.preload['sha2']
no file './sha2.lua'
no file './/logs/sha2.lua'
no file './/lualib/sha2.lua'
no file './/lualib/alloc/sha2.lua'
no file './/lualib/enum/sha2.lua'
no file './/lualib/hall/sha2.lua'
no file './/lualib/login/sha2.lua'
no file './/lualib/module/sha2.lua'
no file './/lualib/table/sha2.lua'
no file './/module_info/sha2.lua'
no file './/proto/sha2.lua'
no file './/script/sha2.lua'
no file '../../common/sha2.lua'
no file '../../common//enum/sha2.lua'
no file '../../common//msg/sha2.lua'
no file '../../common//proto/sha2.lua'
no file '../../skynet_fly/lualib/sha2.lua'
no file '../../skynet_fly/lualib/cache/sha2.lua'
no file '../../skynet_fly/lualib/check/sha2.lua'
no file '../../skynet_fly/lualib/client/sha2.lua'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.