srs
srs copied to clipboard
Config: Support overwrite by environment virable.
srs的配置文件是否考虑切换成yaml,毕竟配置文件可能需要被很多文件读取和解析。使用通用的结构。可以方便各种语言直接使用类库读写。
考虑如下场景:srs需要读取其他配置文件的配置项,或者其他组件需要读取srs的配置项。
k8s默认使用yaml格式,spring也支持yaml格式。从业务角度,yaml是比较被广泛使用的配置文件格式(特别是docker内)
比对可以参考wiki https://en.wikipedia.org/wiki/YAML#Comparison_with_JSON 设计目标可以参考https://yaml.org/spec/1.2/spec.html#id2708649
当然,yaml的空格问题必须要借助工具,否则可读性就差了那么点意思。
https://json.schemastore.org/github-workflow.json
One advantage of using yml is that it provides prompts while writing, making it suitable for configuration files.
It is more beginner-friendly and can be assisted by IDE for configuration.

TRANS_BY_GPT3
After supporting YAML or JSON, it is more convenient for JavaScript to read and write, making it easier to create management systems.
Configuration files are essentially APIs for the system, and it is best if they can be accessed by JavaScript. In essence, HTTP APIs are also the same.
Therefore, supporting this feature is very beneficial for usability.
Since this feature doubles the maintenance workload, with both conf and yaml/json configurations, the work for reload and utest also doubles. Therefore, we need to consider whether to support yaml or json, and can only choose one.
TRANS_BY_GPT3
I found the configuration file for NGINX is not good, with two issues:
-
The format is conf, which is not as easily parsed as yaml.
-
It is only possible to start the container through a file, which can be cumbersome.
Actually, YAML cannot solve the second problem either. On the contrary, Redis is very good at it. It is all simple key-value configuration, for example:
# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
This is the configuration file, and it can also be specified through the command line:
redis-server /etc/redis.conf --port 16379
For containers, command line parameters or environment variables are more user-friendly. Configuration files like conf and yaml are not ideal.
Refer to the Redis Configuration documentation for more information.
Usage: ./redis-server [/path/to/redis.conf] [options]
./redis-server - (read config from stdin)
./redis-server -v or --version
./redis-server -h or --help
./redis-server --test-memory <megabytes>
Examples:
./redis-server (run the server with default conf)
./redis-server /etc/redis/6379.conf
./redis-server --port 7777
./redis-server --port 7777 --replicaof 127.0.0.1 8888
./redis-server /etc/myredis.conf --loglevel verbose
Sentinel mode:
./redis-server /etc/sentinel.conf --sentinel
In other words, we should actually support the Redis approach rather than YAML, for example:
./objs/srs -c conf/srs.conf --listen 19350 --hls.enabled on
We can ignore vhost because it's too troublesome. We only need to support the configuration of the default vhost. This way, when starting the SRS container, it will be very convenient to specify these parameters and very user-friendly.
TRANS_BY_GPT3
What was said earlier is incorrect. The best way to configure Grafana is through environment variables. The new configuration for SRS will also support overriding through environment variables, which is ideal for cloud-native environments.
For example, to start Grafana:
docker run --rm -it --name grafana \
--env GF_SECURITY_ADMIN_USER=admin \
--env GF_SECURITY_ADMIN_PASSWORD=12345678 \
--env GF_DATABASE_TYPE=mysql \
--env GF_DATABASE_HOST=host.docker.internal:3306 \
--env GF_DATABASE_NAME=grafana \
--env GF_DATABASE_USER=root \
--env GF_DATABASE_PASSWORD= \
--env GF_INSTALL_PLUGINS=tencentcloud-monitor-app \
-p 3000:3000 \
grafana/grafana
Using the local MySQL, install a plugin and specify all settings through environment variables. This makes it very convenient to start in K8s or similar Docker environments.
TRANS_BY_GPT3