From ea305790df6c2f23b19f8e4b228ab8ae812253a8 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 26 Feb 2020 16:38:06 +0800 Subject: [PATCH 1/8] For #1579, refactor log for gracefully quit. --- trunk/src/app/srs_app_server.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 632ff9fc5..9cffa3250 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -554,9 +554,11 @@ void SrsServer::gracefully_dispose() close_listeners(SrsListenerMpegTsOverUdp); close_listeners(SrsListenerRtsp); close_listeners(SrsListenerFlv); + srs_trace("listeners closed"); // Fast stop to notify FFMPEG to quit, wait for a while then fast kill. ingester->stop(); + srs_trace("ingesters stopped"); // Wait for connections to quit. // While gracefully quiting, user can requires SRS to fast quit. @@ -572,6 +574,7 @@ void SrsServer::gracefully_dispose() // dispose the source for hls and dvr. _srs_sources->dispose(); + srs_trace("source disposed"); #ifdef SRS_AUTO_MEM_WATCH srs_memory_report(); From d5bbf84439ed4aefcdc7f0a549b629ccf4780339 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 5 Mar 2020 11:34:16 +0800 Subject: [PATCH 2/8] Release 3.0b2, 3.0.123 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index e72c4e14f..da2fed7f8 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-03-05, [3.0 beta2(3.0.123)][r3.0b2] released. 122170 lines. * v3.0, 2020-02-21, For [#1598][bug #1598], support SLB health checking by TCP. 3.0.123 * v3.0, 2020-02-21, Fix bug for librtmp client ipv4/ipv6 socket. 3.0.122 * v3.0, 2020-02-18, For [#1579][bug #1579], support start/final wait for gracefully quit. 3.0.121 @@ -745,6 +746,7 @@ For previous versions, please read: ## Releases +* 2020-03-05, [Release v3.0-b2][r3.0b2], 3.0 beta2, 3.0.123, 122170 lines. * 2020-02-14, [Release v3.0-b1][r3.0b1], 3.0 beta1, 3.0.117, 121964 lines. * 2020-02-02, [Release v3.0-b0][r3.0b0], 3.0 beta0, 3.0.112, 121709 lines. * 2020-01-21, [Release v3.0-a9][r3.0a9], 3.0 alpha9, 3.0.105, 121577 lines. @@ -1662,6 +1664,7 @@ Winlin [exo #828]: https://github.com/google/ExoPlayer/pull/828 +[r3.0b2]: https://github.com/ossrs/srs/releases/tag/v3.0-b2 [r3.0b1]: https://github.com/ossrs/srs/releases/tag/v3.0-b1 [r3.0b0]: https://github.com/ossrs/srs/releases/tag/v3.0-b0 [r3.0a9]: https://github.com/ossrs/srs/releases/tag/v3.0-a9 From 927c0c8e398e9fbc0d2e43f19b60f4cdb805b5e4 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 11 Mar 2020 19:04:52 +0800 Subject: [PATCH 3/8] For #1634, fix quit by accident SIGTERM while killing FFMPEG. 3.0.124 --- README.md | 2 ++ trunk/src/app/srs_app_process.cpp | 4 ++++ trunk/src/app/srs_app_server.cpp | 7 ++++--- trunk/src/core/srs_core_version3.hpp | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index da2fed7f8..ca451c970 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-03-11, For [#1634][bug #1634], fix quit by accident SIGTERM while killing FFMPEG. 3.0.124 * v3.0, 2020-03-05, [3.0 beta2(3.0.123)][r3.0b2] released. 122170 lines. * v3.0, 2020-02-21, For [#1598][bug #1598], support SLB health checking by TCP. 3.0.123 * v3.0, 2020-02-21, Fix bug for librtmp client ipv4/ipv6 socket. 3.0.122 @@ -1660,6 +1661,7 @@ Winlin [bug #1601]: https://github.com/ossrs/srs/issues/1601 [bug #1579]: https://github.com/ossrs/srs/issues/1579 [bug #1598]: https://github.com/ossrs/srs/issues/1598 +[bug #1634]: https://github.com/ossrs/srs/issues/1634 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/app/srs_app_process.cpp b/trunk/src/app/srs_app_process.cpp index 8ccc1b72e..0f12f493d 100644 --- a/trunk/src/app/srs_app_process.cpp +++ b/trunk/src/app/srs_app_process.cpp @@ -248,6 +248,10 @@ srs_error_t SrsProcess::start() // parent. if (pid > 0) { + // Wait for a while for process to really started. + // @see https://github.com/ossrs/srs/issues/1634#issuecomment-597568840 + srs_usleep(10 * SRS_UTIME_MILLISECONDS); + is_started = true; srs_trace("fored process, pid=%d, bin=%s, stdout=%s, stderr=%s, argv=%s", pid, bin.c_str(), stdout_file.c_str(), stderr_file.c_str(), actual_cli.c_str()); diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 9cffa3250..99724f993 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -892,6 +892,7 @@ srs_error_t SrsServer::cycle() void SrsServer::on_signal(int signo) { if (signo == SRS_SIGNAL_RELOAD) { + srs_trace("reload config, signo=%d", signo); signal_reload = true; return; } @@ -899,7 +900,7 @@ void SrsServer::on_signal(int signo) #ifndef SRS_AUTO_GPERF_MC if (signo == SRS_SIGNAL_REOPEN_LOG) { _srs_log->reopen(); - srs_warn("reopen log file"); + srs_warn("reopen log file, signo=%d", signo); return; } #endif @@ -907,7 +908,7 @@ void SrsServer::on_signal(int signo) #ifdef SRS_AUTO_GPERF_MC if (signo == SRS_SIGNAL_REOPEN_LOG) { signal_gmc_stop = true; - srs_warn("for gmc, the SIGUSR1 used as SIGINT"); + srs_warn("for gmc, the SIGUSR1 used as SIGINT, signo=%d", signo); return; } #endif @@ -919,7 +920,7 @@ void SrsServer::on_signal(int signo) if (signo == SIGINT) { #ifdef SRS_AUTO_GPERF_MC - srs_trace("gmc is on, main cycle will terminate normally."); + srs_trace("gmc is on, main cycle will terminate normally, signo=%d", signo); signal_gmc_stop = true; #else #ifdef SRS_AUTO_MEM_WATCH diff --git a/trunk/src/core/srs_core_version3.hpp b/trunk/src/core/srs_core_version3.hpp index c871670b0..982408222 100644 --- a/trunk/src/core/srs_core_version3.hpp +++ b/trunk/src/core/srs_core_version3.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION3_HPP #define SRS_CORE_VERSION3_HPP -#define SRS_VERSION3_REVISION 123 +#define SRS_VERSION3_REVISION 124 #endif From 66b194cd63c12b4de54ed75c422960144e9ea0e1 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 11 Mar 2020 19:08:36 +0800 Subject: [PATCH 4/8] For #1634, refactor encoder process management. --- trunk/src/app/srs_app_encoder.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/trunk/src/app/srs_app_encoder.cpp b/trunk/src/app/srs_app_encoder.cpp index 346bd2715..b2164ebde 100644 --- a/trunk/src/app/srs_app_encoder.cpp +++ b/trunk/src/app/srs_app_encoder.cpp @@ -94,15 +94,17 @@ srs_error_t SrsEncoder::cycle() srs_error_t err = srs_success; while (true) { - if ((err = do_cycle()) != srs_success) { - srs_warn("Encoder: Ignore error, %s", srs_error_desc(err).c_str()); - srs_error_reset(err); - } - + // We always check status first. + // @see https://github.com/ossrs/srs/issues/1634#issuecomment-597571561 if ((err = trd->pull()) != srs_success) { err = srs_error_wrap(err, "encoder"); break; } + + if ((err = do_cycle()) != srs_success) { + srs_warn("Encoder: Ignore error, %s", srs_error_desc(err).c_str()); + srs_error_reset(err); + } srs_usleep(SRS_RTMP_ENCODER_CIMS); } From c78595c1fa4eacab4b41458289b03d043dd631c2 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 11 Mar 2020 19:19:17 +0800 Subject: [PATCH 5/8] For #1634, refactor encoder output, support timestamp variables. --- trunk/src/app/srs_app_encoder.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/trunk/src/app/srs_app_encoder.cpp b/trunk/src/app/srs_app_encoder.cpp index b2164ebde..1f4aae4ee 100644 --- a/trunk/src/app/srs_app_encoder.cpp +++ b/trunk/src/app/srs_app_encoder.cpp @@ -33,6 +33,7 @@ using namespace std; #include #include #include +#include // for encoder to detect the dead loop static std::vector _transcoded_url; @@ -284,6 +285,7 @@ srs_error_t SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, Sr output = srs_string_replace(output, "[stream]", req->stream); output = srs_string_replace(output, "[param]", req->param); output = srs_string_replace(output, "[engine]", engine->arg0()); + output = srs_path_build_timestamp(output); std::string log_file = SRS_CONSTS_NULL_FILE; // disabled // write ffmpeg info to log file. From 0290009b4edf6c1b4e3a50dc7a896b1e56a78ddb Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 11 Mar 2020 19:27:26 +0800 Subject: [PATCH 6/8] Refine readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca451c970..c5ef94865 100755 --- a/README.md +++ b/README.md @@ -1662,7 +1662,7 @@ Winlin [bug #1579]: https://github.com/ossrs/srs/issues/1579 [bug #1598]: https://github.com/ossrs/srs/issues/1598 [bug #1634]: https://github.com/ossrs/srs/issues/1634 -[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx +[bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy [exo #828]: https://github.com/google/ExoPlayer/pull/828 From c61c2a939fffb13f33298645f44ef4e3b4fe33d3 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 11 Mar 2020 19:33:55 +0800 Subject: [PATCH 7/8] For #1634, refactor output with datetime for ingest/encoder/exec. 3.0.125 --- README.md | 1 + trunk/conf/full.conf | 30 ++++++++++++++++++++++++++++ trunk/src/app/srs_app_ingest.cpp | 1 + trunk/src/app/srs_app_ng_exec.cpp | 2 ++ trunk/src/core/srs_core_version3.hpp | 2 +- 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5ef94865..ae034b22d 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-03-11, For [#1634][bug #1634], refactor output with datetime for ingest/encoder/exec. 3.0.125 * v3.0, 2020-03-11, For [#1634][bug #1634], fix quit by accident SIGTERM while killing FFMPEG. 3.0.124 * v3.0, 2020-03-05, [3.0 beta2(3.0.123)][r3.0b2] released. 122170 lines. * v3.0, 2020-02-21, For [#1598][bug #1598], support SLB health checking by TCP. 3.0.123 diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index b56f27fbc..f25a84073 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -978,6 +978,16 @@ vhost exec.srs.com { # [tcUrl] the client request tcUrl. # [swfUrl] the client request swfUrl. # [pageUrl] the client request pageUrl. + # we also support datetime variables. + # [2006], replace this const to current year. + # [01], replace this const to current month. + # [02], replace this const to current date. + # [15], replace this const to current hour. + # [04], replace this const to current minute. + # [05], replace this const to current second. + # [999], replace this const to current millisecond. + # [timestamp],replace this const to current UNIX timestamp in ms. + # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]" # @remark empty to ignore this exec. publish ./objs/ffmpeg/bin/ffmpeg -f flv -i [url] -c copy -y ./[stream].flv; } @@ -1331,6 +1341,16 @@ vhost ingest.srs.com { # output stream. variables: # [vhost] current vhost which start the ingest. # [port] system RTMP stream port. + # we also support datetime variables. + # [2006], replace this const to current year. + # [01], replace this const to current month. + # [02], replace this const to current date. + # [15], replace this const to current hour. + # [04], replace this const to current minute. + # [05], replace this const to current second. + # [999], replace this const to current millisecond. + # [timestamp],replace this const to current UNIX timestamp in ms. + # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]" output rtmp://127.0.0.1:[port]/live?vhost=[vhost]/livestream; } } @@ -1519,6 +1539,16 @@ vhost example.transcode.srs.com { # [app] the input stream app. # [stream] the input stream name. # [engine] the transcode engine name. + # we also support datetime variables. + # [2006], replace this const to current year. + # [01], replace this const to current month. + # [02], replace this const to current date. + # [15], replace this const to current hour. + # [04], replace this const to current minute. + # [05], replace this const to current second. + # [999], replace this const to current millisecond. + # [timestamp],replace this const to current UNIX timestamp in ms. + # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]" output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; } } diff --git a/trunk/src/app/srs_app_ingest.cpp b/trunk/src/app/srs_app_ingest.cpp index c98ed7d04..addbd9bc2 100644 --- a/trunk/src/app/srs_app_ingest.cpp +++ b/trunk/src/app/srs_app_ingest.cpp @@ -382,6 +382,7 @@ srs_error_t SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* // ie. rtmp://localhost:1935/live/livestream_sd output = srs_string_replace(output, "[vhost]", vhost->arg0()); output = srs_string_replace(output, "[port]", srs_int2str(port)); + output = srs_path_build_timestamp(output); if (output.empty()) { return srs_error_new(ERROR_ENCODER_NO_OUTPUT, "empty output url, ingest=%s", ingest->arg0().c_str()); } diff --git a/trunk/src/app/srs_app_ng_exec.cpp b/trunk/src/app/srs_app_ng_exec.cpp index a1e613c8e..17941a00c 100644 --- a/trunk/src/app/srs_app_ng_exec.cpp +++ b/trunk/src/app/srs_app_ng_exec.cpp @@ -219,6 +219,8 @@ string SrsNgExec::parse(SrsRequest* req, string tmpl) output = srs_string_replace(output, "[tcUrl]", req->tcUrl); output = srs_string_replace(output, "[swfUrl]", req->swfUrl); output = srs_string_replace(output, "[pageUrl]", req->pageUrl); + + output = srs_path_build_timestamp(output); if (output.find("[url]") != string::npos) { string url = srs_generate_rtmp_url(req->host, req->port, req->host, req->vhost, req->app, req->stream, req->param); diff --git a/trunk/src/core/srs_core_version3.hpp b/trunk/src/core/srs_core_version3.hpp index 982408222..8a69c55d2 100644 --- a/trunk/src/core/srs_core_version3.hpp +++ b/trunk/src/core/srs_core_version3.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION3_HPP #define SRS_CORE_VERSION3_HPP -#define SRS_VERSION3_REVISION 124 +#define SRS_VERSION3_REVISION 125 #endif From 6c55fd3e4bc9cb158e445908a6a1191c3150ff0e Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 11 Mar 2020 19:42:42 +0800 Subject: [PATCH 8/8] For #1634, refactor output with datetime for ingest/encoder/exec. 3.0.125 --- trunk/src/app/srs_app_ng_exec.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/trunk/src/app/srs_app_ng_exec.cpp b/trunk/src/app/srs_app_ng_exec.cpp index 17941a00c..18d719e78 100644 --- a/trunk/src/app/srs_app_ng_exec.cpp +++ b/trunk/src/app/srs_app_ng_exec.cpp @@ -35,6 +35,7 @@ using namespace std; #include #include #include +#include SrsNgExec::SrsNgExec() {