Config: Support overwrote by environment variables. (#3197)

* Support overwrite by environment virable.

* modify duplicated code

* Config: Add stat for envrionment config.

* Config: Fix utest fail.

Co-authored-by: pengfei.ma <pengfei.ma@ctechm.com>
Co-authored-by: winlin <winlin@vip.126.com>
pull/3200/head
mapengfei53 2 years ago committed by GitHub
parent dc20d5ddbc
commit eb04f92176
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="private" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="-c console.conf" 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>
<env name="SRS_RTC_SERVER_ENABLED" value="on" />
</envs>
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>

@ -15,58 +15,69 @@ server_id srs-ie193id;
# The pid file to write the pid, for managing the SRS process and avoiding duplicated processes.
# If need to run multiple processes, please change this pid file to another one.
# Note: Do not support reloading, for SRS5+
# Overwrite by env SRS_PID
# Default: ./objs/srs.pid
pid ./objs/srs.pid;
# the log dir for FFMPEG.
# if enabled ffmpeg, each transcoding stream will create a log file.
# /dev/null to disable the log.
# Note: Do not support reloading, for SRS5+
# Overwrite by env SRS_FF_LOG_DIR
# default: ./objs
ff_log_dir ./objs;
# the log level for FFMPEG.
# info warning error fatal panic quiet
# trace debug verbose
# Note: Do not support reloading, for SRS5+
# Overwrite by env SRS_FF_LOG_LEVEL
# default: info
ff_log_level info;
# the log tank, console or file.
# if console, print log to console.
# if file, write log to file. requires srs_log_file if log to file.
# Note: Do not support reloading, for SRS5+
# Overwrite by env SRS_SRS_LOG_TANK
# default: file.
srs_log_tank console;
# the log level, for all log tanks.
# can be: verbose, info, trace, warn, error
# Note: Do not support reloading, for SRS5+
# Overwrite by env SRS_SRS_LOG_LEVEL
# default: trace
srs_log_level trace;
# when srs_log_tank is file, specifies the log file.
# Note: Do not support reloading, for SRS5+
# Overwrite by env SRS_SRS_LOG_FILE
# default: ./objs/srs.log
srs_log_file ./objs/srs.log;
# the max connections.
# if exceed the max connections, server will drop the new connection.
# Overwrite by env SRS_MAX_CONNECTIONS
# default: 1000
max_connections 1000;
# whether start as daemon
# @remark: do not support reload.
# Overwrite by env SRS_DAEMON
# default: on
daemon off;
# whether use utc_time to generate the time struct,
# if off, use localtime() to generate it,
# if on, use gmtime() instead, which use UTC time.
# Note: Do not support reloading, for SRS5+
# Overwrite by env SRS_UTC_TIME
# default: off
utc_time off;
# config for the pithy print in ms,
# which always print constant message specified by interval,
# whatever the clients in concurrency.
# Overwrite by env SRS_PITHY_PRINT_MS
# default: 10000
pithy_print_ms 10000;
# the work dir for server, to chdir(work_dir) when not empty or "./"
# user can config this directory to change the dir.
# @reamrk do not support reload.
# Overwrite by env SRS_WORK_DIR
# default: ./
work_dir ./;
# whether quit when parent process changed,
@ -74,42 +85,51 @@ work_dir ./;
# supervisor process exited.
# @remark conflict with daemon, error when both daemon and asprocess are on.
# @reamrk do not support reload.
# Overwrite by env SRS_ASPROCESS
# default: off
asprocess off;
# Whether client empty IP is ok, for example, health checking by SLB.
# If ok(on), we will ignore this connection without warnings or errors.
# Overwrite by env SRS_EMPTY_IP_OK
# 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.
# Overwrite by env SRS_IN_DOCKER
# 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.
# @see https://github.com/ossrs/srs/issues/1595#issuecomment-587516567
# Overwrite by env SRS_GRACE_START_WAIT
# 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
# Overwrite by env SRS_GRACE_FINAL_WAIT
# 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
# Overwrite by env SRS_FORCE_GRACE_QUIT
# default: off
force_grace_quit off;
# Whether disable daemon for docker.
# If on, it will set daemon to off in docker, even daemon is on.
# Overwrite by env SRS_DISABLE_DAEMON_FOR_DOCKER
# default: on
disable_daemon_for_docker on;
# Whether auto reload by watching the config file by inotify.
# Overwrite by env SRS_INOTIFY_AUTO_RELOAD
# default: off
inotify_auto_reload off;
# Whether enable inotify_auto_reload for docker.
# If on, it will set inotify_auto_reload to on in docker, even it's off.
# Overwrite by env SRS_AUTO_RELOAD_FOR_DOCKER
# default: on
auto_reload_for_docker on;
@ -125,6 +145,7 @@ listen 1935;
# some client does not support chunk size change,
# however, most clients support it and it can improve
# performance about 10%.
# Overwrite by env SRS_CHUNK_SIZE
# default: 60000
chunk_size 60000;
@ -150,17 +171,20 @@ http_api {
# Default: 1985
listen 8080;
# whether enable crossdomain request.
# Overwrite by env SRS_HTTP_API_CROSSDOMAIN
# default: on
crossdomain on;
# the HTTP RAW API is more powerful api to change srs state and reload.
raw_api {
# whether enable the HTTP RAW API.
# Overwrite by env SRS_HTTP_API_RAW_API_ENABLED
# default: off
enabled off;
# whether enable rpc reload.
# default: off
allow_reload off;
# whether enable rpc query.
# Overwrite by env SRS_HTTP_API_RAW_API_ALLOW_RELOAD
# Always off by https://github.com/ossrs/srs/issues/2653
#allow_query off;
# whether enable rpc update.
@ -181,10 +205,12 @@ http_api {
listen 8088;
# The SSL private key file, generated by:
# openssl genrsa -out server.key 2048
# Overwrite by env SRS_HTTP_API_HTTPS_KEY
# default: ./conf/server.key
key ./conf/server.key;
# The SSL public cert file, generated by:
# openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net"
# Overwrite by env SRS_HTTP_API_HTTPS_CERT
# default: ./conf/server.crt
cert ./conf/server.crt;
}
@ -212,28 +238,32 @@ http_server {
# default: 8080
listen 8080;
# the default dir for http root.
# Overwrite by env SRS_HTTP_SERVER_DIR
# default: ./objs/nginx/html
dir ./objs/nginx/html;
# whether enable crossdomain request.
# for both http static and stream server and apply on all vhosts.
# Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN
# default: on
crossdomain on;
# For https_server or HTTPS Streaming.
https {
# Whether enable HTTPS Streaming.
# Overwrite by env SRS_HTTP_SERVER_HTTTPS_ENABLED
# Overwrite by env SRS_HTTP_SERVER_HTTPS_ENABLED
# default: off
enabled on;
# The listen endpoint for HTTPS Streaming.
# Overwrite by env SRS_HTTP_SERVER_HTTTPS_LISTEN
# Overwrite by env SRS_HTTP_SERVER_HTTPS_LISTEN
# default: 8088
listen 8088;
# The SSL private key file, generated by:
# openssl genrsa -out server.key 2048
# Overwrite by env SRS_HTTP_SERVER_HTTPS_KEY
# default: ./conf/server.key
key ./conf/server.key;
# The SSL public cert file, generated by:
# openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net"
# Overwrite by env SRS_HTTP_SERVER_HTTPS_CERT
# default: ./conf/server.crt
cert ./conf/server.crt;
}
@ -245,9 +275,11 @@ http_server {
# @doc https://github.com/ossrs/srs/issues/1147#usage
srt_server {
# whether SRT server is enabled.
# Overwrite by env SRS_SRT_SERVER_ENABLED
# default: off
enabled on;
# The UDP listen port for SRT.
# Overwrite by env SRS_SRT_SERVER_LISTEN
listen 10080;
# For detail parameters, please read wiki:
# @see https://ossrs.net/lts/zh-cn/docs/v5/doc/srt-params
@ -256,50 +288,63 @@ srt_server {
# -1: Means the biggest bandwidth is infinity.
# 0: Means the bandwidth is determined by SRTO_INPUTBW.
# >0: Means the bandwidth is the configuration value.
# Overwrite by env SRS_SRT_SERVER_MAXBW
# default: -1
maxbw 1000000000;
# The timeout time of the SRT connection on the sender side in ms. When SRT connects to a peer costs time
# more than this config, it will be close.
# Overwrite by env SRS_SRT_SERVER_CONNECT_TIMEOUT
# default: 3000
connect_timeout 4000;
# The timeout time of SRT connection on the receiver side in ms. When the SRT connection is idle
# more than this config, it will be close.
# Overwrite by env SRS_SRT_SERVER_PEER_IDLE_TIMEOUT
# default: 10000
peer_idle_timeout 8000;
# Default app for vmix, see https://github.com/ossrs/srs/pull/1615
# Overwrite by env SRS_SRT_SERVER_DEFAULT_APP
# default: live
default_app live;
# The peerlatency is set by the sender side and will notify the receiver side.
# Overwrite by env SRS_SRT_SERVER_PEERLATENCY
# default: 0
peerlatency 0;
# The recvlatency means latency from sender to receiver.
# Overwrite by env SRS_SRT_SERVER_RECVLATENCY
# default: 120
recvlatency 0;
# This latency configuration configures both recvlatency and peerlatency to the same value.
# Overwrite by env SRS_SRT_SERVER_LATENCY
# default: 120
latency 0;
# The tsbpd mode means timestamp based packet delivery.
# SRT sender side will pack timestamp in each packet. If this config is true,
# the receiver will read the packet according to the timestamp in the head of the packet.
# Overwrite by env SRS_SRT_SERVER_TSBPDMODE
# default: on
tsbpdmode off;
# The tlpkdrop means too-late Packet Drop
# SRT sender side will pack timestamp in each packet, When the network is congested,
# the packet will drop if latency is bigger than the configuration in both sender side and receiver side.
# And on the sender side, it also will be dropped because latency is bigger than configuration.
# Overwrite by env SRS_SRT_SERVER_TLPKDROP_TLPKTDROP
# default: on
tlpktdrop off;
# The send buffer size of SRT.
# Overwrite by env SRS_SRT_SERVER_SENDBUF
# default: 8192 * (1500-28)
sendbuf 2000000;
# The recv buffer size of SRT.
# Overwrite by env SRS_SRT_SERVER_RECVBUF
# default: 8192 * (1500-28)
recvbuf 2000000;
}
vhost srt.vhost.srs.com {
srt {
# Overwrite by env SRS_SRT_ENABLED for all vhosts.
enabled on;
# Overwrite by env SRS_SRT_TO_RTMP for all vhosts.
srt_to_rtmp on;
}
}
@ -379,19 +424,23 @@ rtc_server {
keep_api_domain off;
# Whether use ECDSA certificate.
# If not, use RSA certificate.
# Overwrite by env SRS_RTC_SERVER_ECDSA
# default: on
ecdsa on;
# Whether encrypt RTP packet by SRTP.
# @remark Should always turn it on, or Chrome will fail.
# Overwrite by env SRS_RTC_SERVER_ENCRYPT
# default: on
encrypt on;
# We listen multiple times at the same port, by REUSEPORT, to increase the UDP queue.
# Note that you can set to 1 and increase the system UDP buffer size by net.core.rmem_max
# and net.core.rmem_default or just increase this to get larger UDP recv and send buffer.
# Overwrite by env SRS_RTC_SERVER_REUSEPORT
# default: 1
reuseport 1;
# Whether merge multiple NALUs into one.
# @see https://github.com/ossrs/srs/issues/307#issuecomment-612806318
# Overwrite by env SRS_RTC_SERVER_MERGE_NALUS
# default: off
merge_nalus off;
# The black-hole to copy packet to, for debugging.
@ -400,9 +449,11 @@ rtc_server {
# we are able to capture the plaintext packets by wireshark.
black_hole {
# Whether enable the black-hole.
# Overwrite by env SRS_RTC_SERVER_BLACK_HOLE_ENABLED
# default: off
enabled off;
# The black-hole address for session.
# Overwrite by env SRS_RTC_SERVER_BLACK_HOLE_ADDR
addr 127.0.0.1:10000;
}
}
@ -414,28 +465,36 @@ vhost rtc.vhost.srs.com {
# default: off
enabled on;
# Whether support NACK.
# Overwrite by env SRS_VHOST_RTC_NACK for all vhosts.
# default: on
nack on;
# Whether directly use the packet, avoid copy.
# Overwrite by env SRS_VHOST_RTC_NACK_NO_COPY for all vhosts.
# default: on
nack_no_copy on;
# Whether support TWCC.
# Overwrite by env SRS_VHOST_RTC_TWCC for all vhosts.
# default: on
twcc on;
# The timeout in seconds for session timeout.
# Client will send ping(STUN binding request) to server, we use it as heartbeat.
# Overwrite by env SRS_VHOST_RTC_STUN_TIMEOUT for all vhosts.
# default: 30
stun_timeout 30;
# The strict check when process stun.
# Overwrite by env SRS_VHOST_RTC_STUN_STRICT_CHECK for all vhosts.
# default: off
stun_strict_check on;
# The role of dtls when peer is actpass: passive or active
# Overwrite by env SRS_VHOST_RTC_DTLS_ROLE for all vhosts.
# default: passive
dtls_role passive;
# The version of dtls, support dtls1.0, dtls1.2, and auto
# Overwrite by env SRS_VHOST_RTC_DTLS_VERSION for all vhosts.
# default: auto
dtls_version auto;
# Drop the packet with the pt(payload type), 0 never drop.
# Overwrite by env SRS_VHOST_RTC_DROP_FOR_PT for all vhosts.
# default: 0
drop_for_pt 0;
###############################################################
@ -446,6 +505,7 @@ vhost rtc.vhost.srs.com {
rtmp_to_rtc off;
# Whether keep B-frame, which is normal feature in live streaming,
# but usually disabled in RTC.
# Overwrite by env SRS_VHOST_RTC_KEEP_BFRAME for all vhosts.
# default: off
keep_bframe off;
###############################################################
@ -455,22 +515,26 @@ vhost rtc.vhost.srs.com {
rtc_to_rtmp off;
# The PLI interval in seconds, for RTC to RTMP.
# Note the available range is [0.5, 30]
# Overwrite by env SRS_VHOST_RTC_PLI_FOR_RTMP for all vhosts.
# Default: 6.0
pli_for_rtmp 6.0;
}
###############################################################
# For transmuxing RTMP to RTC, it will impact the default values if RTC is on.
# Whether enable min delay mode for vhost.
# Overwrite by env SRS_VHOST_MIN_LATENCY for all vhosts.
# default: on, for RTC.
min_latency on;
play {
# set the MW(merged-write) latency in ms.
# @remark For WebRTC, we enable pass-by-timestamp mode, so we ignore this config.
# Overwrite by env SRS_VHOST_PLAY_MW_LATENCY for all vhosts.
# default: 0 (For WebRTC)
mw_latency 0;
# Set the MW(merged-write) min messages.
# default: 0 (For Real-Time, that is min_latency on)
# default: 1 (For WebRTC, that is min_latency off)
# Overwrite by env SRS_VHOST_PLAY_MW_MSGS for all vhosts.
mw_msgs 0;
}
}
@ -525,12 +589,14 @@ stream_caster {
# For tcmalloc, the release rate.
# @see https://gperftools.github.io/gperftools/tcmalloc.html
# @remark Should run configure --with-gperf
# Overwrite by env SRS_TCMALLOC_RELEASE_RATE
# default: 0.8
tcmalloc_release_rate 0.8;
# Query the latest available version of SRS, write a log to notice user to upgrade.
# @see https://github.com/ossrs/srs/issues/2424
# @see https://github.com/ossrs/srs/issues/2508
# Overwrite by env SRS_QUERY_LATEST_VERSION
# Default: on
query_latest_version on;
@ -543,6 +609,7 @@ first_wait_for_qlv 300;
# For thread pool.
threads {
# The thread pool manager cycle interval, in seconds.
# Overwrite by env SRS_THREADS_INTERVAL
# Default: 5
interval 5;
}
@ -550,30 +617,37 @@ threads {
# For system circuit breaker.
circuit_breaker {
# Whether enable the circuit breaker.
# Overwrite by env SRS_CIRCUIT_BREAKER_ENABLED
# Default: on
enabled on;
# The CPU percent(0, 100) ever 1s, as system high water-level, which enable the circuit-break
# mechanism, for example, NACK will be disabled if high water-level.
# Overwrite by env SRS_CIRCUIT_BREAKER_HIGH_THRESHOLD
# Default: 90
high_threshold 90;
# Reset the high water-level, if number of pulse under high_threshold.
# @remark 0 to disable the high water-level.
# Overwrite by env SRS_CIRCUIT_BREAKER_HIGH_PULSE
# Default: 2
high_pulse 2;
# The CPU percent(0, 100) ever 1s, as system critical water-level, which enable the circuit-break
# mechanism, for example, TWCC will be disabled if high water-level.
# @note All circuit-break mechanism of high-water-level scope are enabled in critical.
# Overwrite by env SRS_CIRCUIT_BREAKER_CRITICAL_THRESHOLD
# Default: 95
critical_threshold 95;
# Reset the critical water-level, if number of pulse under critical_threshold.
# @remark 0 to disable the critical water-level.
# Overwrite by env SRS_CIRCUIT_BREAKER_CRITICAL_PULSE
# Default: 1
critical_pulse 1;
# If dying, also drop packets for players.
# Overwrite by env SRS_CIRCUIT_BREAKER_DYING_THRESHOLD
# Default: 99
dying_threshold 99;
# If CPU exceed the dying_pulse times, enter dying.
# @remark 0 to disable the dying water-level.
# Overwrite by env SRS_CIRCUIT_BREAKER_DYING_PULSE
# Default: 5
dying_pulse 5;
}
@ -685,10 +759,12 @@ exporter {
# which need the config item stats.network.
heartbeat {
# whether heartbeat is enabled.
# Overwrite by env SRS_HEARTBEAT_ENABLED
# default: off
enabled off;
# the interval seconds for heartbeat,
# recommend 0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,3,...,6,9,12,....
# Overwrite by env SRS_HEARTBEAT_INTERVAL
# default: 9.9
interval 9.3;
# when startup, srs will heartbeat to this api.
@ -697,9 +773,11 @@ heartbeat {
# "device_id": "my-srs-device",
# "ip": "192.168.1.100"
# }
# Overwrite by env SRS_HEARTBEAT_URL
# default: http://127.0.0.1:8085/api/v1/servers
url http://127.0.0.1:8085/api/v1/servers;
# the id of device.
# Overwrite by env SRS_HEARTBEAT_DEVICE_ID
device_id "my-srs-device";
# whether report with summaries
# if on, put /api/v1/summaries to the request data:
@ -707,6 +785,7 @@ heartbeat {
# "summaries": summaries object.
# }
# @remark: optional config.
# Overwrite by env SRS_HEARTBEAT_SUMMARIES
# default: off
summaries off;
}
@ -757,6 +836,7 @@ vhost scope.vhost.srs.com {
# whether enable the TCP_NODELAY
# if on, set the nodelay of fd by setsockopt
# Overwrite by env SRS_VHOST_TCP_NODELAY for all vhosts.
# default: off
tcp_nodelay off;
@ -942,11 +1022,13 @@ vhost play.srs.com {
# client need to wait for the next Iframe to decode and show the video.
# set to off if requires min delay;
# set to on if requires client fast startup.
# Overwrite by env SRS_VHOST_PLAY_GOP_CACHE for all vhosts.
# default: on
gop_cache off;
# the max live queue length in seconds.
# if the messages in the queue exceed the max length,
# drop the old whole gop.
# Overwrite by env SRS_VHOST_PLAY_QUEUE_LENGTH for all vhosts.
# default: 30
queue_length 10;
@ -962,6 +1044,7 @@ vhost play.srs.com {
# 3. off, disable the time jitter algorithm, like atc.
# @remark for full, correct timestamp only when |delta| > 250ms.
# @remark disabled when atc is on.
# Overwrite by env SRS_VHOST_PLAY_TIME_JITTER for all vhosts.
# default: full
time_jitter full;
# vhost for atc for hls/hds/rtmp backup.
@ -976,12 +1059,14 @@ vhost play.srs.com {
# @see http://www.baidu.com/#wd=hds%20hls%20atc
#
# @remark when atc is on, auto off the time_jitter
# Overwrite by env SRS_VHOST_PLAY_ATC for all vhosts.
# default: off
atc off;
# whether use the interleaved/mixed algorithm to correct the timestamp.
# if on, always ensure the timestamp of audio+video is interleaved/mixed monotonically increase.
# if off, use time_jitter to correct the timestamp if required.
# @remark to use mix_correct, atc should on(or time_jitter should off).
# Overwrite by env SRS_VHOST_PLAY_MIX_CORRECT for all vhosts.
# default: off
mix_correct off;
@ -989,6 +1074,7 @@ vhost play.srs.com {
# if enabled, detect the bravo_atc="true" in onMetaData packet,
# set atc to on if matched.
# always ignore the onMetaData if atc_auto is off.
# Overwrite by env SRS_VHOST_PLAY_ATC_AUTO for all vhosts.
# default: off
atc_auto off;
@ -998,6 +1084,7 @@ vhost play.srs.com {
# the value recomment is [300, 1800]
# @remark For WebRTC, we enable pass-by-timestamp mode, so we ignore this config.
# default: 350 (For RTMP/HTTP-FLV)
# Overwrite by env SRS_VHOST_PLAY_MW_LATENCY for all vhosts.
# default: 0 (For WebRTC)
mw_latency 350;
@ -1005,6 +1092,7 @@ vhost play.srs.com {
# default: 0 (For Real-Time, min_latency on)
# default: 1 (For WebRTC, min_latency off)
# default: 8 (For RTMP/HTTP-FLV, min_latency off).
# Overwrite by env SRS_VHOST_PLAY_MW_MSGS for all vhosts.
mw_msgs 8;
# the minimal packets send interval in ms,
@ -1014,11 +1102,13 @@ vhost play.srs.com {
# @remark 0 to disable the minimal interval.
# @remark >0 to make the srs to send message one by one.
# @remark user can get the right packets interval in ms by srs_rtmp_dump.
# Overwrite by env SRS_VHOST_PLAY_SEND_MIN_INTERVAL for all vhosts.
# default: 0
send_min_interval 10.0;
# whether reduce the sequence header,
# for some client which cannot got duplicated sequence header,
# while the sequence header is not changed yet.
# Overwrite by env SRS_VHOST_PLAY_REDUCE_SEQUENCE_HEADER for all vhosts.
# default: off
reduce_sequence_header on;
}
@ -1132,6 +1222,7 @@ vhost publish.srs.com {
publish {
# about MR, read https://github.com/ossrs/srs/issues/241
# when enabled the mr, SRS will read as large as possible.
# Overwrite by env SRS_VHOST_PUBLISH_MR for all vhosts.
# default: off
mr off;
# the latency in ms for MR(merged-read),
@ -1142,22 +1233,27 @@ vhost publish.srs.com {
# when there are 2500 publisher, the total memory of SRS at least:
# 183KB * 2500 = 446MB
# the recommended value is [300, 2000]
# Overwrite by env SRS_VHOST_PUBLISH_MR_LATENCY for all vhosts.
# default: 350
mr_latency 350;
# the 1st packet timeout in ms for encoder.
# Overwrite by env SRS_VHOST_PUBLISH_FIRSTPKT_TIMEOUT for all vhosts.
# default: 20000
firstpkt_timeout 20000;
# the normal packet timeout in ms for encoder.
# Overwrite by env SRS_VHOST_PUBLISH_NORMAL_TIMEOUT for all vhosts.
# default: 5000
normal_timeout 7000;
# whether parse the sps when publish stream.
# we can got the resolution of video for stat api.
# but we may failed to cause publish failed.
# @remark If disabled, HLS might never update the sps/pps, it depends on this.
# Overwrite by env SRS_VHOST_PUBLISH_PARSE_SPS for all vhosts.
# default: on
parse_sps on;
# When parsing SPS/PPS, whether try ANNEXB first. If not, try IBMF first, then ANNEXB.
# Overwrite by env SRS_VHOST_PUBLISH_TRY_ANNEXB_FIRST for all vhosts.
# default: on
try_annexb_first on;
}
@ -1226,6 +1322,7 @@ vhost http.static.srs.com {
# http static vhost specified config
http_static {
# whether enabled the http static service for vhost.
# Overwrite by env SRS_VHOST_HTTP_STATIC_ENABLED for all vhosts.
# default: off
enabled on;
# the url to mount to,
@ -1246,11 +1343,13 @@ vhost http.static.srs.com {
# access by http://ossrs.net:8080/hls/xxx.html
# or by http://192.168.1.173:8080/hls/xxx.html
# @remark the port of http is specified by http_server section.
# Overwrite by env SRS_VHOST_HTTP_STATIC_MOUNT for all vhosts.
# default: [vhost]/
mount [vhost]/hls;
# main dir of vhost,
# to delivery HTTP stream of this vhost.
# default: ./objs/nginx/html
# Overwrite by env SRS_VHOST_HTTP_STATIC_DIR for all vhosts.
dir ./objs/nginx/html/hls;
}
}
@ -1260,12 +1359,14 @@ vhost http.remux.srs.com {
# http flv/mp3/aac/ts stream vhost specified config
http_remux {
# whether enable the http live streaming service for vhost.
# Overwrite by env SRS_VHOST_HTTP_REMUX_ENABLED for all vhosts.
# default: off
enabled on;
# the fast cache for audio stream(mp3/aac),
# to cache more audio and send to client in a time to make android(weixin) happy.
# @remark the flv/ts stream ignore it
# @remark 0 to disable fast cache for http audio stream.
# Overwrite by env SRS_VHOST_HTTP_REMUX_FAST_CACHE for all vhosts.
# default: 0
fast_cache 30;
# the stream mount for rtmp to remux to live streaming.
@ -1293,6 +1394,7 @@ vhost http.remux.srs.com {
# mount to [vhost]/[app]/[stream].ts
# access by http://ossrs.net:8080/live/livestream.ts
# @remark the port of http is specified by http_server section.
# Overwrite by env SRS_VHOST_HTTP_REMUX_MOUNT for all vhosts.
# default: [vhost]/[app]/[stream].flv
mount [vhost]/[app]/[stream].flv;
}
@ -1460,25 +1562,31 @@ vhost dash.srs.com {
dash {
# Whether DASH is enabled.
# Transmux RTMP to DASH if on.
# Overwrite by env SRS_VHOST_DASH_ENABLED for all vhosts.
# Default: off
enabled on;
# The duration of segment in seconds.
# Overwrite by env SRS_VHOST_DASH_DASH_FRAGMENT for all vhosts.
# Default: 30
dash_fragment 30;
# The period to update the MPD in seconds.
# Overwrite by env SRS_VHOST_DASH_DASH_UPDATE_PERIOD for all vhosts.
# Default: 150
dash_update_period 150;
# The depth of timeshift buffer in seconds.
# Overwrite by env SRS_VHOST_DASH_DASH_TIMESHIFT for all vhosts.
# Default: 300
dash_timeshift 300;
# The base/home dir/path for dash.
# All init and segment files will write under this dir.
# Overwrite by env SRS_VHOST_DASH_DASH_PATH for all vhosts.
dash_path ./objs/nginx/html;
# The DASH MPD file path.
# We supports some variables to generate the filename.
# [vhost], the vhost of stream.
# [app], the app of stream.
# [stream], the stream name of stream.
# Overwrite by env SRS_VHOST_DASH_DASH_MPD_FILE for all vhosts.
# Default: [app]/[stream].mpd
dash_mpd_file [app]/[stream].mpd;
}

File diff suppressed because it is too large Load Diff

@ -27,6 +27,9 @@ using namespace std;
// Whether we are in docker, defined in main module.
extern bool _srs_in_docker;
// Whether setup config by environment variables.
extern bool _srs_config_by_env;
// Check the feature by cond
#define SRS_CHECK_FEATURE(cond, ss) if (cond) ss << "&" << #cond << "=1"
#define SRS_CHECK_FEATURE2(cond, key, ss) if (cond) ss << "&" << key << "=1"
@ -159,6 +162,7 @@ void srs_build_features(stringstream& ss)
SRS_CHECK_FEATURE(exec, ss);
SRS_CHECK_FEATURE(transcode, ss);
SRS_CHECK_FEATURE(security, ss);
SRS_CHECK_FEATURE2(_srs_config_by_env, "env", ss);
SRS_CHECK_FEATURE2(_srs_cls->enabled(), "cls", ss);
SRS_CHECK_FEATURE3(_srs_cls->nn_logs(), "logs", _srs_cls->nn_logs(), ss);

@ -1421,7 +1421,7 @@ string srs_string_dumps_hex(const char* str, int length, int limit, char seperat
return string(buf, len);
}
string srs_getenv(string key)
string srs_getenv(const string& key)
{
string ekey = key;
if (srs_string_starts_with(key, "$")) {
@ -1432,6 +1432,15 @@ string srs_getenv(string key)
return "";
}
std::string::iterator it;
for (it = ekey.begin(); it != ekey.end(); ++it) {
if (*it >= 'a' && *it <= 'z') {
*it += ('A' - 'a');
} else if (*it == '.') {
*it = '_';
}
}
char* value = ::getenv(ekey.c_str());
if (value) {
return value;

@ -685,7 +685,7 @@ extern std::string srs_string_dumps_hex(const char* str, int length, int limit,
// Get ENV variable, which may starts with $.
// srs_getenv("EIP") === srs_getenv("$EIP")
extern std::string srs_getenv(std::string key);
extern std::string srs_getenv(const std::string& key);
#endif

@ -68,10 +68,13 @@ extern const char* _srs_version;
// @global main SRS server, for debugging
SrsServer* _srs_server = NULL;
// Whether setup config by environment variables, see https://github.com/ossrs/srs/issues/2277
bool _srs_config_by_env = false;
/**
* main entrance.
*/
srs_error_t do_main(int argc, char** argv)
srs_error_t do_main(int argc, char** argv, char** envp)
{
srs_error_t err = srs_success;
@ -130,12 +133,21 @@ srs_error_t do_main(int argc, char** argv)
return srs_error_wrap(err, "log initialize");
}
// Detect whether set SRS config by envrionment variables.
for (char** pp = envp; *pp; pp++) {
char* p = *pp;
if (p[0] == 'S' && p[1] == 'R' && p[2] == 'S' && p[3] == '_') {
_srs_config_by_env = true;
break;
}
}
// config already applied to log.
srs_trace2(TAG_MAIN, "%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE);
srs_trace("%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE);
srs_trace("authors: %sand %s", RTMP_SIG_SRS_AUTHORS, SRS_CONSTRIBUTORS);
srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d, pkg: %s, region: %s, source: %s",
_srs_config->cwd().c_str(), cwd.c_str(), SRS_BUILD_DATE, SRS_USER_CONFIGURE, SRS_UNAME, SRS_OSX_BOOL, SRS_PACKAGER,
srs_getenv("SRS_REGION").c_str(), srs_getenv("SRS_SOURCE").c_str());
srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d, env: %d, pkg: %s",
_srs_config->cwd().c_str(), cwd.c_str(), SRS_BUILD_DATE, SRS_USER_CONFIGURE, SRS_UNAME, SRS_OSX_BOOL,
_srs_config_by_env, SRS_PACKAGER);
srs_trace("configure detail: " SRS_CONFIGURE);
#ifdef SRS_EMBEDED_TOOL_CHAIN
srs_trace("crossbuild tool chain: " SRS_EMBEDED_TOOL_CHAIN);
@ -208,9 +220,9 @@ srs_error_t do_main(int argc, char** argv)
return err;
}
int main(int argc, char** argv)
int main(int argc, char** argv, char** envp)
{
srs_error_t err = do_main(argc, argv);
srs_error_t err = do_main(argc, argv, envp);
if (err != srs_success) {
srs_error("Failed, %s", srs_error_desc(err).c_str());

@ -35,6 +35,7 @@ ISrsContext* _srs_context = NULL;
SrsConfig* _srs_config = NULL;
SrsServer* _srs_server = NULL;
bool _srs_in_docker = false;
bool _srs_config_by_env = false;
#include <srs_app_st.hpp>

Loading…
Cancel
Save