Skip to content

Commit

Permalink
Merge branch '3.0release' into 4.0release
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Feb 18, 2020
2 parents eefd74e + 58b4047 commit 0c48c42
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ For previous versions, please read:

## V3 changes

* v3.0, 2020-02-18, For [#1579][bug #1579], support force gracefully quit. 3.0.120
* v3.0, 2020-02-18, For [#1579][bug #1579], support gracefully quit. 3.0.119
* v3.0, 2020-02-17, For [#1601][bug #1601], flush async on_dvr/on_hls events before stop. 3.0.118
* <strong>v3.0, 2020-02-14, [3.0 beta1(3.0.117)][r3.0b1] released. 121964 lines.</strong>
Expand Down
9 changes: 8 additions & 1 deletion trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,16 @@ work_dir ./;
# default: off
asprocess off;

# for gracefully quit, final wait for cleanup in milliseconds.
# For gracefully quit, final wait for cleanup in milliseconds.
# @see https://github.com/ossrs/srs/issues/1579#issuecomment-587414898
# default: 3200
grace_final_wait 3200;
# Whether force gracefully quit, never fast quit.
# By default, SIGTERM which means fast quit, is sent by K8S, so we need to
# force SRS to treat SIGTERM as gracefully quit for gray release or canary.
# @see https://github.com/ossrs/srs/issues/1579#issuecomment-587475077
# default: off
force_grace_quit off;

#############################################################################################
# heartbeat/stats sections
Expand Down
14 changes: 13 additions & 1 deletion trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3488,7 +3488,7 @@ srs_error_t SrsConfig::check_normal_config()
&& n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print_ms"
&& n != "http_server" && n != "stream_caster" && n != "srt_server"
&& n != "utc_time" && n != "work_dir" && n != "asprocess"
&& n != "ff_log_level" && n != "grace_final_wait"
&& n != "ff_log_level" && n != "grace_final_wait" && n != "force_grace_quit"
) {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal directive %s", n.c_str());
}
Expand Down Expand Up @@ -4076,6 +4076,18 @@ srs_utime_t SrsConfig::get_grace_final_wait()
return (srs_utime_t)(::atol(conf->arg0().c_str()) * SRS_UTIME_MILLISECONDS);
}

bool SrsConfig::is_force_grace_quit()
{
static bool DEFAULT = false;

SrsConfDirective* conf = root->get("force_grace_quit");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return SRS_CONF_PERFER_FALSE(conf->arg0());
}

vector<SrsConfDirective*> SrsConfig::get_stream_casters()
{
srs_assert(root);
Expand Down
2 changes: 2 additions & 0 deletions trunk/src/app/srs_app_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ class SrsConfig
virtual bool get_asprocess();
// Get the final wait in ms for gracefully quit.
virtual srs_utime_t get_grace_final_wait();
// Whether force to gracefully quit, never fast quit.
virtual bool is_force_grace_quit();
// stream_caster section
public:
// Get all stream_caster in config file.
Expand Down
9 changes: 8 additions & 1 deletion trunk/src/app/srs_app_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,14 @@ void SrsServer::on_signal(int signo)
#endif
#endif
}


// For K8S, force to gracefully quit for gray release or canary.
// @see https://github.com/ossrs/srs/issues/1595#issuecomment-587473037
if (signo == SRS_SIGNAL_FAST_QUIT && _srs_config->is_force_grace_quit()) {
srs_trace("force gracefully quit, signo=%d", signo);
signo = SRS_SIGNAL_GRACEFULLY_QUIT;
}

if ((signo == SIGINT || signo == SRS_SIGNAL_FAST_QUIT) && !signal_fast_quit) {
srs_trace("sig=%d, user terminate program, fast quit", signo);
signal_fast_quit = true;
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
#ifndef SRS_CORE_VERSION3_HPP
#define SRS_CORE_VERSION3_HPP

#define SRS_VERSION3_REVISION 119
#define SRS_VERSION3_REVISION 120

#endif

0 comments on commit 0c48c42

Please sign in to comment.