mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 11:21:52 +00:00
For #1579, support start/final wait for gracefully quit. 3.0.121
This commit is contained in:
parent
58b40478b6
commit
dc0f804452
6 changed files with 28 additions and 2 deletions
|
@ -146,6 +146,7 @@ For previous versions, please read:
|
|||
|
||||
## V3 changes
|
||||
|
||||
* v3.0, 2020-02-18, For [#1579][bug #1579], support start/final wait for gracefully quit. 3.0.121
|
||||
* 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
|
||||
|
|
|
@ -73,6 +73,12 @@ work_dir ./;
|
|||
# default: off
|
||||
asprocess off;
|
||||
|
||||
# For gracefully quit, wait for a while then close listeners,
|
||||
# because K8S notify SRS with SIGQUIT and update Service simultaneously,
|
||||
# maybe there is some new connections incoming before Service updated.
|
||||
# @see https://github.com/ossrs/srs/issues/1595#issuecomment-587516567
|
||||
# default: 2300
|
||||
grace_start_wait 2300;
|
||||
# For gracefully quit, final wait for cleanup in milliseconds.
|
||||
# @see https://github.com/ossrs/srs/issues/1579#issuecomment-587414898
|
||||
# default: 3200
|
||||
|
|
|
@ -3488,6 +3488,7 @@ srs_error_t SrsConfig::check_normal_config()
|
|||
&& n != "http_server" && n != "stream_caster"
|
||||
&& n != "utc_time" && n != "work_dir" && n != "asprocess"
|
||||
&& n != "ff_log_level" && n != "grace_final_wait" && n != "force_grace_quit"
|
||||
&& n != "grace_start_wait"
|
||||
) {
|
||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal directive %s", n.c_str());
|
||||
}
|
||||
|
@ -4050,6 +4051,18 @@ bool SrsConfig::get_asprocess()
|
|||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
srs_utime_t SrsConfig::get_grace_start_wait()
|
||||
{
|
||||
static srs_utime_t DEFAULT = 2300 * SRS_UTIME_MILLISECONDS;
|
||||
|
||||
SrsConfDirective* conf = root->get("grace_start_wait");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return (srs_utime_t)(::atol(conf->arg0().c_str()) * SRS_UTIME_MILLISECONDS);
|
||||
}
|
||||
|
||||
srs_utime_t SrsConfig::get_grace_final_wait()
|
||||
{
|
||||
static srs_utime_t DEFAULT = 3200 * SRS_UTIME_MILLISECONDS;
|
||||
|
|
|
@ -468,6 +468,8 @@ public:
|
|||
virtual std::string get_work_dir();
|
||||
// Whether use asprocess mode.
|
||||
virtual bool get_asprocess();
|
||||
// Get the start wait in ms for gracefully quit.
|
||||
virtual srs_utime_t get_grace_start_wait();
|
||||
// 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.
|
||||
|
|
|
@ -543,6 +543,10 @@ void SrsServer::gracefully_dispose()
|
|||
{
|
||||
_srs_config->unsubscribe(this);
|
||||
|
||||
// Always wait for a while to start.
|
||||
srs_usleep(_srs_config->get_grace_start_wait());
|
||||
srs_trace("start wait for %dms", srsu2msi(_srs_config->get_grace_start_wait()));
|
||||
|
||||
// prevent fresh clients.
|
||||
close_listeners(SrsListenerRtmpStream);
|
||||
close_listeners(SrsListenerHttpApi);
|
||||
|
@ -574,7 +578,7 @@ void SrsServer::gracefully_dispose()
|
|||
#endif
|
||||
|
||||
srs_usleep(_srs_config->get_grace_final_wait());
|
||||
srs_trace("final wait for another %dms", srsu2msi(_srs_config->get_grace_final_wait()));
|
||||
srs_trace("final wait for %dms", srsu2msi(_srs_config->get_grace_final_wait()));
|
||||
}
|
||||
|
||||
srs_error_t SrsServer::initialize(ISrsServerCycle* ch)
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
#ifndef SRS_CORE_VERSION3_HPP
|
||||
#define SRS_CORE_VERSION3_HPP
|
||||
|
||||
#define SRS_VERSION3_REVISION 120
|
||||
#define SRS_VERSION3_REVISION 121
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue