Configuration

LiveGo can be configured using a YAML file, environment variables, or command-line flags. The configuration is loaded in the following order of precedence (each level overrides the previous):

  1. Default values
  2. Configuration file (livego.yaml by default)
  3. Environment variables
  4. Command-line flags

Configuration File

By default, LiveGo looks for a livego.yaml file in the current directory. You can specify a different file using the --config_file flag.

Example livego.yaml

# Log level: debug, info, warn, error
level: info

# RTMP/RTMPS settings
rtmp_addr: ":1935"
read_timeout: 10
write_timeout: 10
enable_rtmps: false
rtmps_cert: server.crt
rtmps_key: server.key

# HTTP-FLV settings
httpflv_addr: ":7001"

# HLS settings
hls_addr: ":7002"
hls_keep_after_end: false

# HTTP API settings
api_addr: ":8090"

# FLV file archiving options
flv_archive: false
flv_dir: "./tmp"

# Centralized key management
redis_addr: ""
redis_pwd: ""

# JWT Authentication for API
jwt:
  secret: ""
  algorithm: "HS256"

# Application definitions
server:
  - appname: live
    live: true      # Enable RTMP
    hls: true       # Enable HLS
    flv: true       # Enable HTTP-FLV
    api: true       # Enable API access for this app
    static_push: [] # Optional list of RTMP URLs to re-push streams to

Application Configuration (server block)

The server key is an array that defines one or more applications. Each application can have different services enabled.

  • appname: The name of the application (e.g., live). This forms the first part of the stream URL path.
  • live: If true, enables RTMP ingest and playback for this application.
  • hls: If true, enables HLS playback.
  • flv: If true, enables HTTP-FLV playback.
  • api: If true, enables the HTTP API for this application.
  • static_push: An array of RTMP URLs. Any stream published to this application will be automatically re-pushed to these URLs.

Environment Variables

All configuration keys can be set via environment variables. They are uppercase and prefixed, with dots replaced by underscores. For example, rtmp_addr becomes RTMP_ADDR.

  • LEVEL
  • RTMP_ADDR
  • HTTPFLV_ADDR
  • HLS_ADDR
  • API_ADDR
  • REDIS_ADDR
  • REDIS_PWD
  • JWT_SECRET
  • JWT_ALGORITHM

Command-Line Flags

Command-line flags have the highest precedence. You can see all available flags by running livego -h.

Usage of ./livego:
      --api_addr string       HTTP manage interface server listen address (default ":8090")
      --config_file string    configure filename (default "livego.yaml")
      --flv_dir string        output flv file at flvDir/APP/KEY_TIME.flv (default "tmp")
      --gop_num int           gop num (default 1)
      --hls_addr string       HLS server listen address (default ":7002")
      --hls_keep_after_end    Maintains the HLS after the stream ends
      --httpflv_addr string   HTTP-FLV server listen address (default ":7001")
      --level string          Log level (default "info")
      --read_timeout int      read time out (default 10)
      --write_timeout int     write time out (default 10)
      --rtmp_addr string      RTMP server listen address