Skip to content

Commit

Permalink
script 脚本适配录像播放
Browse files Browse the repository at this point in the history
  • Loading branch information
huahua132 committed Oct 24, 2024
1 parent 3df5933 commit 4359ea3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/record/load_mods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ return {
launch_num = 1,
default_arg = {
server_cfg = {
recordfile = "./records/00000010.record" --指定播放录像文件
recordlimit = 1024 * 10,
},

redis = {
Expand Down
8 changes: 5 additions & 3 deletions script/lua/write_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local ARGV = { ... }
local skynet_fly_path = ARGV[1]
local load_mods_name = ARGV[2]
local is_daemon = ARGV[3]
local recordfile = ARGV[4]
assert(skynet_fly_path, '缺少 skynet_fly_path')

package.cpath = skynet_fly_path .. "/luaclib/?.so;"
Expand Down Expand Up @@ -61,7 +62,8 @@ local config = {
lua_path = "",
enablessl = true,
loadmodsfile = load_mods_name, --可热更服务启动配置
recordfile = "",
recordfile = recordfile, --播放录像的文件名
recordlimit = 1024 * 1024 * 100, --录像记录限制(字节数) 超过不再写录像
}

config.lua_path = file_util.create_luapath(skynet_fly_path)
Expand Down Expand Up @@ -109,8 +111,8 @@ if load_mods_f and load_mods_f.share_config_m and load_mods_f.share_config_m.def
if cfg.recordpath then
config.recordpath = cfg.recordpath --录像文件目录
end
if cfg.recordfile then --播放录像时的文件路径
config.recordfile = cfg.recordfile
if cfg.recordlimit then --录像记录限制
config.recordlimit = cfg.recordlimit
end
end

Expand Down
3 changes: 2 additions & 1 deletion script/lua/write_restartsh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ shell_str = shell_str .. [[
if [ "$#" -lt 1 ]; then
echo "arg1 [load_mods] 启动的load_mods配置"
echo "arg2 [is_daemon] 是否守护进程运行 1是0不是 默认1"
echo "arg3 [recordfile] 播放录像文件路径 可选"
echo "please format make/script/restart.sh load_mods is_daemon"
exit 1
fi
]]
shell_str = shell_str .. "sh make/script/stop.sh $1" .. '\n'
shell_str = shell_str .. "sleep 1" .. '\n'
shell_str = shell_str .. "sh make/script/run.sh $1 $2" .. '\n'
shell_str = shell_str .. "sh make/script/run.sh $1 $2 $3" .. '\n'

local shell_path = server_path .. 'make/script/'

Expand Down
5 changes: 3 additions & 2 deletions script/lua/write_runsh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ shell_str = shell_str .. [[
if [ "$#" -lt 1 ]; then
echo "arg1 [load_mods] 启动的load_mods配置"
echo "arg2 [is_daemon] 是否守护进程运行 1是0不是 默认1"
echo "arg3 [recordfile] 播放录像文件路径 可选"
echo "please format make/script/run.sh load_mods.lua is_daemon"
exit 1
fi
]]
shell_str = shell_str .. string.format("echo run %s $1\n",svr_name)
shell_str = shell_str .. string.format("%s %s/write_config.lua %s $1 $2\n",lua_path,script_path,skynet_fly_path)
shell_str = shell_str .. string.format("echo run %s $1 $2 $3\n",svr_name)
shell_str = shell_str .. string.format("%s %s/write_config.lua %s $1 $2 $3\n",lua_path,script_path,skynet_fly_path)
shell_str = shell_str .. string.format("%s %s/console.lua %s %s $1 create_running_config\n",lua_path,script_path,skynet_fly_path,svr_name)
shell_str = shell_str .. string.format("%s %s/console.lua %s %s $1 create_load_mods_old\n",lua_path,script_path,skynet_fly_path,svr_name)
shell_str = shell_str .. string.format("%s/skynet make/%s_config.lua $1\n",skynet_path,svr_name)
Expand Down
8 changes: 7 additions & 1 deletion service/hot_container.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,10 @@ contriner_client:CMD(CMD)

skynet.start(function()
skynet_util.lua_dispatch(CMD)
end)
end)

if IS_RECORD_ON == 1 then
skynet_util.reg_shutdown_func(function()
skynet.recordoff()
end)
end

0 comments on commit 4359ea3

Please sign in to comment.