1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Support config in_docker to fix the detect fail. (#2824). v4.0.216

This commit is contained in:
winlin 2022-01-03 16:55:52 +08:00
parent fd313133b1
commit 7808bd7ca8
6 changed files with 29 additions and 2 deletions

View file

@ -77,6 +77,10 @@ asprocess off;
# default: on # default: on
empty_ip_ok on; empty_ip_ok on;
# Whether in docker. When SRS starting, it will detect the docker, however
# it might detect failed, then read this config.
# Default: off
in_docker off;
# For gracefully quit, wait for a while then close listeners, # For gracefully quit, wait for a while then close listeners,
# because K8S notify SRS with SIGQUIT and update Service simultaneously, # because K8S notify SRS with SIGQUIT and update Service simultaneously,
# maybe there is some new connections incoming before Service updated. # maybe there is some new connections incoming before Service updated.

View file

@ -8,6 +8,7 @@ The changelog for SRS.
## SRS 4.0 Changelog ## SRS 4.0 Changelog
* v4.0, 2021-01-03, For [#2824](https://github.com/ossrs/srs/issues/2824): Support config in_docker to fix the detect fail. (#2824). v4.0.216
* v4.0, 2021-12-31, For [#2728](https://github.com/ossrs/srs/issues/2728): Refine error log for rtmp2rtc. (#2728). v4.0.215 * v4.0, 2021-12-31, For [#2728](https://github.com/ossrs/srs/issues/2728): Refine error log for rtmp2rtc. (#2728). v4.0.215
* v4.0, 2021-12-29, Merge [#2770](https://github.com/ossrs/srs/pull/2770), [#2820](https://github.com/ossrs/srs/pull/2820): Bugs fixed. (#2770)(#2820). v4.0.214 * v4.0, 2021-12-29, Merge [#2770](https://github.com/ossrs/srs/pull/2770), [#2820](https://github.com/ossrs/srs/pull/2820): Bugs fixed. (#2770)(#2820). v4.0.214
* v4.0, 2021-12-27, Fix [#2811](https://github.com/ossrs/srs/issues/2811): Fix ulimit issue by detecting epoll on Ubuntu. (#2811). v4.0.213 * v4.0, 2021-12-27, Fix [#2811](https://github.com/ossrs/srs/issues/2811): Fix ulimit issue by detecting epoll on Ubuntu. (#2811). v4.0.213

View file

@ -2471,7 +2471,7 @@ srs_error_t SrsConfig::check_normal_config()
&& n != "grace_start_wait" && n != "empty_ip_ok" && n != "disable_daemon_for_docker" && n != "grace_start_wait" && n != "empty_ip_ok" && n != "disable_daemon_for_docker"
&& n != "inotify_auto_reload" && n != "auto_reload_for_docker" && n != "tcmalloc_release_rate" && n != "inotify_auto_reload" && n != "auto_reload_for_docker" && n != "tcmalloc_release_rate"
&& n != "query_latest_version" && n != "query_latest_version"
&& n != "circuit_breaker" && n != "is_full" && n != "circuit_breaker" && n != "is_full" && n != "in_docker"
) { ) {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal directive %s", n.c_str()); return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal directive %s", n.c_str());
} }
@ -2999,6 +2999,18 @@ bool SrsConfig::get_daemon()
return SRS_CONF_PERFER_TRUE(conf->arg0()); return SRS_CONF_PERFER_TRUE(conf->arg0());
} }
bool SrsConfig::get_in_docker()
{
static bool DEFAULT = false;
SrsConfDirective* conf = root->get("in_docker");
if (!conf) {
return DEFAULT;
}
return SRS_CONF_PERFER_FALSE(conf->arg0());
}
bool SrsConfig::is_full_config() bool SrsConfig::is_full_config()
{ {
static bool DEFAULT = false; static bool DEFAULT = false;

View file

@ -382,6 +382,8 @@ public:
// If true, SRS will run in daemon mode, fork and fork to reap the // If true, SRS will run in daemon mode, fork and fork to reap the
// grand-child process to init process. // grand-child process to init process.
virtual bool get_daemon(); virtual bool get_daemon();
// Whether srs in docker.
virtual bool get_in_docker();
private: private:
// Whether user use full.conf // Whether user use full.conf
virtual bool is_full_config(); virtual bool is_full_config();

View file

@ -9,6 +9,6 @@
#define VERSION_MAJOR 4 #define VERSION_MAJOR 4
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_REVISION 215 #define VERSION_REVISION 216
#endif #endif

View file

@ -385,6 +385,14 @@ srs_error_t run_directly_or_daemon()
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
// Try to load the config if docker detect failed.
if (!_srs_in_docker) {
_srs_in_docker = _srs_config->get_in_docker();
if (_srs_in_docker) {
srs_trace("enable in_docker by config");
}
}
// Load daemon from config, disable it for docker. // Load daemon from config, disable it for docker.
// @see https://github.com/ossrs/srs/issues/1594 // @see https://github.com/ossrs/srs/issues/1594
bool run_as_daemon = _srs_config->get_daemon(); bool run_as_daemon = _srs_config->get_daemon();