srs-terraform
Terraform a open-source video platform.
Usage
Install dependencies:
cd mgmt && npm install
Run the mgmt backend:
cd mgmt
npm start
Run the mgmt react ui:
cd mgmt/ui
npm start
Access the browser: http://localhost:3000
Ports
The ports allocated:
Module | TCP Ports | UDP Ports | Notes |
---|---|---|---|
SRS | 1935, 1985, 8080, 8088, 1990, 554, 8936 |
8000, 8935, 10080, 1989 |
See SRS ports |
releases | 2023 | - | Mount at /terraform/v1/releases |
mgmt | 2022 | - | Mount at /mgmt/ and /terraform/v1/mgmt/ |
hooks | 2021 | - | Mount at /terraform/v1/hooks/ |
tencent-cloud | 2020 | - | Mount at /terraform/v1/tencent/ |
prometheus | 9090 | - | Mount at /prometheus |
node-exporter | 9100 | - | - |
Features
The features that we're developing:
- A mgmt support authentication and automatic updates.
- Run SRS in docker, query status by docker and SRS API.
- Support publish by RTMP/WebRTC, play by RTMP/HTTP-FLV/HLS/WebRTC.
- SRS container use docker logs
json-file
and rotate for logging. - Support high-resolution and realtime(200~500ms) live streaming by SRT.
- Run SRS hooks in docker, to callback by SRS server.
- Support publish by SRT, play by RTMP/HTTP-FLV/HLS/WebRTC/SRT.
- Integrate with prometheus and node-exporter.
- Support DVR to cloud storage, see #1193.
- Change redis port and use randomly password.
- Support integrity with cloud VoD.
- Support GB28181 by SRS 5.0 container.
- Forward stream to multiple platforms, see #2676.
- Support live streaming transcoding by FFmpeg, see #2869.
- Support virtual live streaming, covert file or other resource to live.
- Support WebRTC face to face chat, see #2857.
- Support WebRTC video chat room, see #2924.
- Support a set of tools for developer, see #2891.
- Collect logs of mgmt and containers together.
- Stop, restart and upgrade containers.
- Support logrotate to manage the logs.
- Enhance prometheus API with authentication.
APIs
Platform:
/terraform/v1/mgmt/versions
Public version api./terraform/v1/mgmt/init
Whether mgmt initialized./terraform/v1/mgmt/check
Check whether system is ok./terraform/v1/mgmt/status
Query the version of mgmt./terraform/v1/mgmt/upgrade
Upgrade the mgmt to latest version./terraform/v1/mgmt/strategy
Toggle the upgrade strategy./terraform/v1/mgmt/token
System auth with token./terraform/v1/mgmt/login
System auth with password./terraform/v1/mgmt/ssl
Config the system SSL config./terraform/v1/mgmt/pubkey
Update the access for platform administrator pubkey./terraform/v1/mgmt/letsencrypt
Config the let's encrypt SSL./terraform/v1/mgmt/containers
Query and upgrade SRS container./terraform/v1/mgmt/bilibili
Query the video information./terraform/v1/mgmt/beian/query
Query the beian information./terraform/v1/mgmt/beian/update
Update the beian information.
Releases:
/terraform/v1/releases
Version management for all components.
Market:
/terraform/v1/hooks/srs/verify
Hooks: Verify the stream request URL of SRS./terraform/v1/hooks/srs/secret/query
Hooks: Query the secret to generate stream URL./terraform/v1/hooks/srs/secret/update
Hooks: Update the secret to generate stream URL./terraform/v1/hooks/srs/hls
Hooks: Handle theon_hls
event./terraform/v1/hooks/dvr/apply
Hooks: Apply the DVR pattern./terraform/v1/hooks/dvr/query
Hooks: Query the DVR pattern./terraform/v1/hooks/dvr/files
Hooks: List the DVR files./terraform/v1/hooks/dvr/hls
Hooks: Generate HLS/m3u8 url to preview or download./terraform/v1/tencent/cam/secret
Tencent: Setup the CAM SecretId and SecretKey./prometheus
Prometheus: Time-series database and monitor.
Depends
The software we depend on:
- Docker,
yum install -y docker
- Redis,
yum install -y redis
- Nginx,
yum install -y nginx
- SSL:
/etc/nginx/ssl
- SSL:
- Certbot,
docker --name certbot
- Verify webroot:
mgmt/containers/www/.well-known/acme-challenge/
- Cert files:
mgmt/containers/etc/letsencrypt/live/
- Verify webroot:
- SRS,
docker --name srs-server
- Config:
mgmt/containers/conf/srs.conf
mount as/usr/local/srs/conf/lighthouse.conf
- Volume:
mgmt/containers/objs/nginx/html
mount as/usr/local/srs/objs/nginx/html
- Config:
- srs-hooks,
docker --name srs-hooks
- Volume:
mgmt/containers/objs/nginx/html
mount as/usr/local/mgmt/containers/objs/nginx/html
- Volume:
- tencent-cloud,
docker --name tencent-cloud
- CAM Authentication by secretId and secretKey.
- Prometheus,
docker --name prometheus
- Config:
mgmt/containers/conf/prometheus.yml
- Data directory:
mgmt/containers/data/prometheus
- Config:
- NodeExporter,
docker --name node-exporter
Upgrade Workflow
When upgrading automatically or manually by user:
bash upgrade
for each upgrade.
When system start, check the flag SRS_FIRST_BOOT
in redis, if not set:
bash auto/upgrade_prepare
do upgrade for previous images.- Restart container srs-server and srs-hooks, for config changed.
They are not mutually exclusive.
Environments
The optional environments defined by mgmt/.env
:
MGMT_PASSWORD
: The mgmt administrator password.REGION
:ap-guangzhou|ap-singapore
, the region for upgrade source.
For testing the specified service:
NODE_ENV
:development|production
, if development, use local redis; otherwise, usemgmt.srs.local
in docker.LOCAL_RELEASE
:true|false
, whether use local release service.
For github actions to control the containers:
SRS_DOCKER
:srs
to enfore useossrs/srs
docker image.USE_DOCKER
:true|false
, if false, disable all docker containers.