From 170f5500cfe133dabc05229dec85afa818e761fa Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Wed, 12 Jan 2022 17:58:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=BA=AF=E6=BA=90=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=97=B6=E9=97=B4=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/config.ini | 2 ++ server/WebHook.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/conf/config.ini b/conf/config.ini index 708b5ed5..cb2b0602 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -163,6 +163,8 @@ alive_interval=10.0 #http-ts方式: http://127.0.0.1:80/%s/%s.live.ts #支持多个源站,不同源站通过分号(;)分隔 origin_url= +#溯源总超时时长,单位秒,float型;假如源站有3个,那么单次溯源超时时间为timeout_sec除以3 +timeout_sec=15 [http] #http服务器字符编码,windows上默认gb2312 diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 3d302a4c..4dc02ca8 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -72,8 +72,11 @@ onceToken token([](){ namespace Cluster { #define CLUSTER_FIELD "cluster." const string kOriginUrl = CLUSTER_FIELD "origin_url"; +const string kTimeoutSec = CLUSTER_FIELD "timeout_sec"; + static onceToken token([]() { mINI::Instance()[kOriginUrl] = ""; + mINI::Instance()[kTimeoutSec] = 15; }); }//namespace Cluster @@ -234,10 +237,9 @@ static string getPullUrl(const string &origin_fmt, const MediaInfo &info) { static void pullStreamFromOrigin(const vector& urls, int index, int failed_cnt, const MediaInfo &args, const function &closePlayer) { - GET_CONFIG(float, hook_timeout_sec, Hook::kTimeoutSec); - + GET_CONFIG(float, cluster_timeout_sec, Cluster::kTimeoutSec); auto url = getPullUrl(urls[index % urls.size()], args); - auto timeout_sec = hook_timeout_sec / urls.size(); + auto timeout_sec = cluster_timeout_sec / urls.size(); InfoL << "pull stream from origin, failed_cnt: " << failed_cnt << ", timeout_sec: " << timeout_sec << ", url: " << url; addStreamProxy(args._vhost, args._app, args._streamid, url, -1, args._schema == HLS_SCHEMA, false,