diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index 80aadb53e..8bf44582b 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -77,6 +77,10 @@ asprocess off; # default: 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, # because K8S notify SRS with SIGQUIT and update Service simultaneously, # maybe there is some new connections incoming before Service updated. diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index f8dd26861..20c20b217 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,6 +8,7 @@ The changelog for SRS. ## 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-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 diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index fa813737c..d6ea94634 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -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 != "inotify_auto_reload" && n != "auto_reload_for_docker" && n != "tcmalloc_release_rate" && 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()); } @@ -2999,6 +2999,18 @@ bool SrsConfig::get_daemon() 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() { static bool DEFAULT = false; diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index c62351c87..51510b5df 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -382,6 +382,8 @@ public: // If true, SRS will run in daemon mode, fork and fork to reap the // grand-child process to init process. virtual bool get_daemon(); + // Whether srs in docker. + virtual bool get_in_docker(); private: // Whether user use full.conf virtual bool is_full_config(); diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 2d2a72872..34e6eed6c 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 215 +#define VERSION_REVISION 216 #endif diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 643ad83d4..46465c62d 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -385,6 +385,14 @@ srs_error_t run_directly_or_daemon() { 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. // @see https://github.com/ossrs/srs/issues/1594 bool run_as_daemon = _srs_config->get_daemon();