Config: Support set env_only by SRS_ENV_ONLY.

pull/3224/head
winlin 2 years ago
parent 9f7a06bc9e
commit 9673bfb92c

@ -1,6 +1,7 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="env" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="-e" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" WORKING_DIR="file://$CMakeCurrentBuildDir$/../../../" PASS_PARENT_ENVS_2="true" PROJECT_NAME="srs" TARGET_NAME="srs" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="srs" RUN_TARGET_NAME="srs"> <configuration default="false" name="env" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" WORKING_DIR="file://$CMakeCurrentBuildDir$/../../../" PASS_PARENT_ENVS_2="true" PROJECT_NAME="srs" TARGET_NAME="srs" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="srs" RUN_TARGET_NAME="srs">
<envs> <envs>
<env name="SRS_ENV_ONLY" value="on" />
<env name="SRS_LISTEN" value="1935" /> <env name="SRS_LISTEN" value="1935" />
<env name="SRS_EXPORTER_ENABLED" value="on" /> <env name="SRS_EXPORTER_ENABLED" value="on" />
</envs> </envs>

@ -1848,6 +1848,9 @@ srs_error_t SrsConfig::parse_options(int argc, char** argv)
// first hello message. // first hello message.
srs_trace(_srs_version); srs_trace(_srs_version);
// Config the env_only_ by env.
if (getenv("SRS_ENV_ONLY")) env_only_ = true;
// Try config files as bellow: // Try config files as bellow:
// User specified config(not empty), like user/docker.conf // User specified config(not empty), like user/docker.conf
// If user specified *docker.conf, try *srs.conf, like user/srs.conf // If user specified *docker.conf, try *srs.conf, like user/srs.conf

@ -275,6 +275,7 @@ private:
// Whether show SRS signature and exit. // Whether show SRS signature and exit.
bool show_signature; bool show_signature;
// Whether only use environment variable, ignore config file. // Whether only use environment variable, ignore config file.
// Set it by argv "-e" or env "SRS_ENV_ONLY=on".
bool env_only_; bool env_only_;
// global env variables. // global env variables.
private: private:

Loading…
Cancel
Save