openvidu部署

2023-05-16

1、简介

OpenVidu Server(openvidu-server):是openvidu平台的大脑,负责信号层。

Kurento Media Server(kms):openvidu平台的核心,负责媒体层。

Coturm(coturn):用于允许在特殊网络上与浏览器媒体交互的服务器。

Redis(redis):管理Coturn服务器上的用户

Nginx(nginx):反向代理。用于配置SSL证书并且允许Openvidu服务器与应用通过443端口服务。

Videoconference Application(app):openvidu会话应用或者其他应用。可以禁用。

2、安装

sudo su切换到su用户,执行下面脚本

curl https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/install_openvidu_latest.sh | bash

会因为网络原因执行失败。可以先下载脚本,看其逻辑。

install_openvidu_latest.sh脚本如下

#!/usr/bin/env bash

# Global variables
OPENVIDU_FOLDER=openvidu
OPENVIDU_VERSION=v2.20.0
OPENVIDU_UPGRADABLE_VERSION="2.19"
DOWNLOAD_URL=https://raw.githubusercontent.com/OpenVidu/openvidu/${OPENVIDU_VERSION}

fatal_error() {
     printf "\n     =======隆ERROR!======="
     printf "\n     %s" "$1"
     printf "\n"
     exit 0
}

new_ov_installation() {
     printf '\n'
     printf '\n     ======================================='
     printf '\n          Install OpenVidu CE %s' "${OPENVIDU_VERSION}"
     printf '\n     ======================================='
     printf '\n'

     # Create folder openvidu-docker-compose
     printf '\n     => Creating folder '%s'...' "${OPENVIDU_FOLDER}"
     mkdir "${OPENVIDU_FOLDER}" || fatal_error "Error while creating the folder '${OPENVIDU_FOLDER}'"

     # Download necessary files
     printf '\n     => Downloading OpenVidu CE files:'

     curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/ce/docker-compose/.env \
          --output "${OPENVIDU_FOLDER}/.env" || fatal_error "Error when downloading the file '.env'"
     printf '\n          - .env'

     curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/ce/docker-compose/docker-compose.override.yml \
          --output "${OPENVIDU_FOLDER}/docker-compose.override.yml" || fatal_error "Error when downloading the file 'docker-compose.override.yml'"
     printf '\n          - docker-compose.override.yml'

     curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/ce/docker-compose/docker-compose.yml \
          --output "${OPENVIDU_FOLDER}/docker-compose.yml" || fatal_error "Error when downloading the file 'docker-compose.yml'"
     printf '\n          - docker-compose.yml'

     curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/ce/docker-compose/openvidu \
          --output "${OPENVIDU_FOLDER}/openvidu" || fatal_error "Error when downloading the file 'openvidu'"
     printf '\n          - openvidu'

     # Add execution permissions
     printf "\n     => Adding permission to 'openvidu' program..."
     chmod +x "${OPENVIDU_FOLDER}/openvidu" || fatal_error "Error while adding permission to 'openvidu' program"

     # Change recording folder with all permissions
     printf "\n     => Adding permission to 'recordings' folder..."
     mkdir -p "${OPENVIDU_FOLDER}/recordings"
     chmod 777 "${OPENVIDU_FOLDER}/recordings"

     # Create own certificated folder
     printf "\n     => Creating folder 'owncert'..."
     mkdir "${OPENVIDU_FOLDER}/owncert" || fatal_error "Error while creating the folder 'owncert'"

     # Create vhost nginx folder
     printf "\n     => Creating folder 'custom-nginx-vhosts'..."
     mkdir "${OPENVIDU_FOLDER}/custom-nginx-vhosts" || fatal_error "Error while creating the folder 'custom-nginx-vhosts'"

     # Ready to use
     printf '\n'
     printf '\n'
     printf '\n     ======================================='
     printf '\n     Openvidu Platform successfully installed.'
     printf '\n     ======================================='
     printf '\n'
     printf '\n     1. Go to openvidu folder:'
     printf '\n     $ cd openvidu'
     printf '\n'
     printf '\n     2. Configure DOMAIN_OR_PUBLIC_IP and OPENVIDU_SECRET in .env file:'
     printf '\n     $ nano .env'
     printf '\n'
     printf '\n     3. Start OpenVidu'
     printf '\n     $ ./openvidu start'
     printf '\n'
     printf '\n     For more information, check:'
     printf '\n     https://docs.openvidu.io/en/%s/deployment/deploying-on-premises/' "${OPENVIDU_VERSION//v}"
     printf '\n'
     printf '\n'
     exit 0
}

upgrade_ov() {
     # Search local Openvidu installation
     printf '\n'
     printf '\n     ============================================'
     printf '\n       Search Previous Installation of Openvidu'
     printf '\n     ============================================'
     printf '\n'

     SEARCH_IN_FOLDERS=(
          "${PWD}"
          "/opt/${OPENVIDU_FOLDER}"
     )

     for folder in "${SEARCH_IN_FOLDERS[@]}"; do
          printf "\n     => Searching in '%s' folder..." "${folder}"

          if [ -f "${folder}/docker-compose.yml" ]; then
               OPENVIDU_PREVIOUS_FOLDER="${folder}"

               printf "\n     => Found installation in folder '%s'" "${folder}"
               break
          fi
     done

     [ -z "${OPENVIDU_PREVIOUS_FOLDER}" ] && fatal_error "No previous Openvidu installation found"

     # Upgrade Openvidu
     OPENVIDU_PREVIOUS_VERSION=$(grep 'Openvidu Version:' "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml" | awk '{ print $4 }')
     [ -z "${OPENVIDU_PREVIOUS_VERSION}" ] && fatal_error "Can't find previous OpenVidu version"

     # In this point using the variable 'OPENVIDU_PREVIOUS_VERSION' we can verify if the upgrade is
     # posible or not. If it is not posible launch a warning and stop the upgrade.
     if [[ "${OPENVIDU_PREVIOUS_VERSION}" != "${OPENVIDU_UPGRADABLE_VERSION}."* ]]; then
          fatal_error "You can't update from version ${OPENVIDU_PREVIOUS_VERSION} to ${OPENVIDU_VERSION}.\nNever upgrade across multiple major versions."
     fi

     printf '\n'
     printf '\n     ======================================='
     printf '\n       Upgrade OpenVidu CE %s to %s' "${OPENVIDU_PREVIOUS_VERSION}" "${OPENVIDU_VERSION}"
     printf '\n     ======================================='
     printf '\n'

     ROLL_BACK_FOLDER="${OPENVIDU_PREVIOUS_FOLDER}/.old-${OPENVIDU_PREVIOUS_VERSION}"
     TMP_FOLDER="${OPENVIDU_PREVIOUS_FOLDER}/tmp"
     ACTUAL_FOLDER="$PWD"
     USE_OV_CALL=$(grep -E '^        image: openvidu/openvidu-call:.*$' "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.override.yml" | tr -d '[:space:]')

     printf "\n     Creating rollback folder '%s'..." ".old-${OPENVIDU_PREVIOUS_VERSION}"
     mkdir "${ROLL_BACK_FOLDER}" || fatal_error "Error while creating the folder '.old-${OPENVIDU_PREVIOUS_VERSION}'"

     printf "\n     Creating temporal folder 'tmp'..."
     mkdir "${TMP_FOLDER}" || fatal_error "Error while creating the folder 'temporal'"

     # Download necessary files
     printf '\n     => Downloading new OpenVidu CE files:'

     curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/ce/docker-compose/docker-compose.yml \
          --output "${TMP_FOLDER}/docker-compose.yml" || fatal_error "Error when downloading the file 'docker-compose.yml'"
     printf '\n          - docker-compose.yml'

     curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/ce/docker-compose/docker-compose.override.yml \
          --output "${TMP_FOLDER}/docker-compose.override.yml" || fatal_error "Error when downloading the file 'docker-compose.override.yml'"
     printf "\n          - docker-compose.override.yml"

     curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/ce/docker-compose/.env \
          --output "${TMP_FOLDER}/.env" || fatal_error "Error when downloading the file '.env'"
     printf '\n          - .env'

     curl --silent ${DOWNLOAD_URL}/openvidu-server/deployments/ce/docker-compose/openvidu \
          --output "${TMP_FOLDER}/openvidu" || fatal_error "Error when downloading the file 'openvidu'"
     printf '\n          - openvidu'

     # Downloading new images and stopped actual Openvidu
     printf '\n     => Downloading new images...'
     printf '\n'
     sleep 1

     printf "\n          => Moving to 'tmp' folder..."
     printf '\n'
     cd "${TMP_FOLDER}" || fatal_error "Error when moving to 'tmp' folder"
     docker-compose pull || true

     printf '\n     => Stopping Openvidu...'
     printf '\n'
     sleep 1

     printf "\n          => Moving to 'openvidu' folder..."
     printf '\n'
     cd "${OPENVIDU_PREVIOUS_FOLDER}" || fatal_error "Error when moving to 'openvidu' folder"
     docker-compose down || true

     printf '\n'
     printf '\n     => Moving to working dir...'
     cd "${ACTUAL_FOLDER}" || fatal_error "Error when moving to working dir"

     # Move old files to rollback folder
     printf '\n     => Moving previous installation files to rollback folder:'

     mv "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous 'docker-compose.yml'"
     printf '\n          - docker-compose.yml'

     if [ -n "${USE_OV_CALL}" ]; then
          mv "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.override.yml" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous 'docker-compose.override.yml'"
          printf '\n          - docker-compose.override.yml'
     fi

     mv "${OPENVIDU_PREVIOUS_FOLDER}/openvidu" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous 'openvidu'"
     printf '\n          - openvidu'

     cp "${OPENVIDU_PREVIOUS_FOLDER}/.env" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous '.env'"
     printf '\n          - .env'

     if [ -d "${OPENVIDU_PREVIOUS_FOLDER}/custom-nginx-vhosts" ]; then
          mv "${OPENVIDU_PREVIOUS_FOLDER}/custom-nginx-vhosts" "${ROLL_BACK_FOLDER}" || fatal_error "Error while moving previous directory 'custom-nginx-vhosts'"
          printf '\n          - custom-nginx-vhosts'
     fi

     # Move tmp files to Openvidu
     printf '\n     => Updating files:'

     mv "${TMP_FOLDER}/docker-compose.yml" "${OPENVIDU_PREVIOUS_FOLDER}" || fatal_error "Error while updating 'docker-compose.yml'"
     printf '\n          - docker-compose.yml'

     if [ -n "${USE_OV_CALL}" ]; then
          mv "${TMP_FOLDER}/docker-compose.override.yml" "${OPENVIDU_PREVIOUS_FOLDER}" || fatal_error "Error while updating 'docker-compose.override.yml'"
          printf '\n          - docker-compose.override.yml'
     else
          mv "${TMP_FOLDER}/docker-compose.override.yml" "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.override.yml-${OPENVIDU_VERSION}" || fatal_error "Error while updating 'docker-compose.override.yml'"
          printf '\n          - docker-compose.override.yml-%s' "${OPENVIDU_VERSION}"
     fi

     mv "${TMP_FOLDER}/.env" "${OPENVIDU_PREVIOUS_FOLDER}/.env-${OPENVIDU_VERSION}" || fatal_error "Error while moving previous '.env'"
     printf '\n          - .env-%s' "${OPENVIDU_VERSION}"

     mv "${TMP_FOLDER}/openvidu" "${OPENVIDU_PREVIOUS_FOLDER}" || fatal_error "Error while updating 'openvidu'"
     printf '\n          - openvidu'

     printf "\n     => Deleting 'tmp' folder"
     rm -rf "${TMP_FOLDER}" || fatal_error "Error deleting 'tmp' folder"

     # Add execution permissions
     printf "\n     => Adding permission to 'openvidu' program..."
     chmod +x "${OPENVIDU_PREVIOUS_FOLDER}/openvidu" || fatal_error "Error while adding permission to 'openvidu' program"

     # Change recording folder with all permissions
     printf "\n     => Adding permission to 'recordings' folder..."
     mkdir -p "${OPENVIDU_PREVIOUS_FOLDER}/recordings"
     chmod 777 "${OPENVIDU_PREVIOUS_FOLDER}/recordings"

     # Define old mode: On Premise or Cloud Formation
     OLD_MODE=$(grep -E "Installation Mode:.*$" "${ROLL_BACK_FOLDER}/docker-compose.yml" | awk '{ print $4,$5 }')
     [ -n "${OLD_MODE}" ] && sed -i -r "s/Installation Mode:.+/Installation Mode: ${OLD_MODE}/" "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml"

     # Ready to use
     printf '\n'
     printf '\n'
     printf '\n     ================================================'
     printf "\n     Openvidu successfully upgraded to version %s" "${OPENVIDU_VERSION}"
     printf '\n     ================================================'
     printf '\n'
     printf "\n     1. A new file 'docker-compose.yml' has been created with the new OpenVidu %s services" "${OPENVIDU_VERSION}"
     printf '\n'
     printf "\n     2. The previous file '.env' remains intact, but a new file '.env-%s' has been created." "${OPENVIDU_VERSION}"
     printf "\n     Transfer any configuration you wish to keep in the upgraded version from '.env' to '.env-%s'." "${OPENVIDU_VERSION}"
     printf "\n     When you are OK with it, rename and leave as the only '.env' file of the folder the new '.env-%s'." "${OPENVIDU_VERSION}"
     printf '\n'
     printf "\n     3. If you were using Openvidu Call application, it has been automatically updated in file 'docker-compose.override.yml'."
     printf "\n     However, if you were using your own application, a file called 'docker-compose.override.yml-%s'" "${OPENVIDU_VERSION}"
     printf "\n     has been created with the latest version of Openvidu Call. If you don't plan to use it you can delete it."
     printf '\n'
     printf '\n     4. Start new version of Openvidu'
     printf '\n     $ ./openvidu start'
     printf '\n'
     printf "\n     If you want to rollback, all the files from the previous installation have been copied to folder '.old-%s'" "${OPENVIDU_PREVIOUS_VERSION}"
     printf '\n'
     printf '\n     For more information, check:'
     printf '\n     https://docs.openvidu.io/en/%s/deployment/deploying-on-premises/' "${OPENVIDU_VERSION//v}"
     printf '\n     https://docs.openvidu.io/en/%s/deployment/upgrading/' "${OPENVIDU_VERSION//v}"
     printf '\n'
     printf '\n'
}

# Check docker and docker-compose installation
if ! command -v docker > /dev/null; then
     echo "You don't have docker installed, please install it and re-run the command"
     exit 0
fi

if ! command -v docker-compose > /dev/null; then
     echo "You don't have docker-compose installed, please install it and re-run the command"
     exit 0
else
     COMPOSE_VERSION=$(docker-compose version --short | sed "s/-rc[0-9]*//")
     if ! printf '%s\n%s\n' "1.24" "$COMPOSE_VERSION" | sort -V -C; then
          echo "You need a docker-compose version equal or higher than 1.24, please update your docker-compose and re-run the command"; \
          exit 0
     fi
fi

# Check type of installation
if [[ -n "$1" && "$1" == "upgrade" ]]; then
     upgrade_ov
else
     new_ov_installation
fi

依次下载

https://raw.githubusercontent.com/OpenVidu/openvidu/v2.20.0/openvidu-server/deployments/ce/docker-compose/.env

https://raw.githubusercontent.com/OpenVidu/openvidu/v2.20.0//openvidu-server/deployments/ce/docker-compose/docker-compose.override.yml

https://raw.githubusercontent.com/OpenVidu/openvidu/v2.20.0/openvidu-server/deployments/ce/docker-compose/docker-compose.yml

https://raw.githubusercontent.com/OpenVidu/openvidu/v2.20.0/openvidu-server/deployments/ce/docker-compose/openvidu

其对应脚本为

.env为

# OpenVidu configuration
# ----------------------
# Documentation: https://docs.openvidu.io/en/stable/reference-docs/openvidu-config/

# NOTE: This file doesn't need to quote assignment values, like most shells do.
# All values are stored as-is, even if they contain spaces, so don't quote them.

# Domain name. If you do not have one, the public IP of the machine.
# For example: 198.51.100.1, or openvidu.example.com
DOMAIN_OR_PUBLIC_IP=

# OpenVidu SECRET used for apps to connect to OpenVidu server and users to access to OpenVidu Dashboard
OPENVIDU_SECRET=

# Certificate type:
# - selfsigned:  Self signed certificate. Not recommended for production use.
#                Users will see an ERROR when connected to web page.
# - owncert:     Valid certificate purchased in a Internet services company.
#                Please put the certificates files inside folder ./owncert
#                with names certificate.key and certificate.cert
# - letsencrypt: Generate a new certificate using letsencrypt. Please set the
#                required contact email for Let's Encrypt in LETSENCRYPT_EMAIL
#                variable.
CERTIFICATE_TYPE=selfsigned

# If CERTIFICATE_TYPE=letsencrypt, you need to configure a valid email for notifications
LETSENCRYPT_EMAIL=user@example.com

# Proxy configuration
# If you want to change the ports on which openvidu listens, uncomment the following lines

# Allows any request to http://DOMAIN_OR_PUBLIC_IP:HTTP_PORT/ to be automatically
# redirected to https://DOMAIN_OR_PUBLIC_IP:HTTPS_PORT/.
# WARNING: the default port 80 cannot be changed during the first boot
# if you have chosen to deploy with the option CERTIFICATE_TYPE=letsencrypt
# HTTP_PORT=80

# Changes the port of all services exposed by OpenVidu.
# SDKs, REST clients and browsers will have to connect to this port
# HTTPS_PORT=443

# Old paths are considered now deprecated, but still supported by default. 
# OpenVidu Server will log a WARN message every time a deprecated path is called, indicating 
# the new path that should be used instead. You can set property SUPPORT_DEPRECATED_API=false 
# to stop allowing the use of old paths.
# Default value is true
# SUPPORT_DEPRECATED_API=true

# If true request to with www will be redirected to non-www requests
# Default value is false
# REDIRECT_WWW=false

# How many workers to configure in nginx proxy. 
# The more workers, the more requests will be handled
# Default value is 10240
# WORKER_CONNECTIONS=10240

# Access restrictions
# In this section you will be able to restrict the IPs from which you can access to
# Openvidu API and the Administration Panel
# WARNING! If you touch this configuration you can lose access to the platform from some IPs.
# Use it carefully.

# This section limits access to the /dashboard (OpenVidu CE) and /inspector (OpenVidu Pro) pages.
# The form for a single IP or an IP range is:
# ALLOWED_ACCESS_TO_DASHBOARD=198.51.100.1 and ALLOWED_ACCESS_TO_DASHBOARD=198.51.100.0/24
# To limit multiple IPs or IP ranges, separate by commas like this:
# ALLOWED_ACCESS_TO_DASHBOARD=198.51.100.1, 198.51.100.0/24
# ALLOWED_ACCESS_TO_DASHBOARD=

# This section limits access to the Openvidu REST API.
# The form for a single IP or an IP range is:
# ALLOWED_ACCESS_TO_RESTAPI=198.51.100.1 and ALLOWED_ACCESS_TO_RESTAPI=198.51.100.0/24
# To limit multiple IPs or or IP ranges, separate by commas like this:
# ALLOWED_ACCESS_TO_RESTAPI=198.51.100.1, 198.51.100.0/24
# ALLOWED_ACCESS_TO_RESTAPI=

# Whether to enable recording module or not
OPENVIDU_RECORDING=false

# Use recording module with debug mode.
OPENVIDU_RECORDING_DEBUG=false

# Openvidu Folder Record used for save the openvidu recording videos. Change it
# with the folder you want to use from your host.
OPENVIDU_RECORDING_PATH=/opt/openvidu/recordings

# System path where OpenVidu Server should look for custom recording layouts
OPENVIDU_RECORDING_CUSTOM_LAYOUT=/opt/openvidu/custom-layout

# if true any client can connect to
# https://OPENVIDU_SERVER_IP:OPENVIDU_PORT/recordings/any_session_file.mp4
# and access any recorded video file. If false this path will be secured with
# OPENVIDU_SECRET param just as OpenVidu Server dashboard at
# https://OPENVIDU_SERVER_IP:OPENVIDU_PORT
# Values: true | false
OPENVIDU_RECORDING_PUBLIC_ACCESS=false

# Which users should receive the recording events in the client side
# (recordingStarted, recordingStopped). Can be all (every user connected to
# the session), publisher_moderator (users with role 'PUBLISHER' or
# 'MODERATOR'), moderator (only users with role 'MODERATOR') or none
# (no user will receive these events)
OPENVIDU_RECORDING_NOTIFICATION=publisher_moderator

# Timeout in seconds for recordings to automatically stop (and the session involved to be closed)
# when conditions are met: a session recording is started but no user is publishing to it or a session
# is being recorded and last user disconnects. If a user publishes within the timeout in either case,
# the automatic stop of the recording is cancelled
# 0 means no timeout
OPENVIDU_RECORDING_AUTOSTOP_TIMEOUT=120

# Maximum video bandwidth sent from clients to OpenVidu Server, in kbps.
# 0 means unconstrained
OPENVIDU_STREAMS_VIDEO_MAX_RECV_BANDWIDTH=1000

# Minimum video bandwidth sent from clients to OpenVidu Server, in kbps.
# 0 means unconstrained
OPENVIDU_STREAMS_VIDEO_MIN_RECV_BANDWIDTH=300

# Maximum video bandwidth sent from OpenVidu Server to clients, in kbps.
# 0 means unconstrained
OPENVIDU_STREAMS_VIDEO_MAX_SEND_BANDWIDTH=1000

# Minimum video bandwidth sent from OpenVidu Server to clients, in kbps.
# 0 means unconstrained
OPENVIDU_STREAMS_VIDEO_MIN_SEND_BANDWIDTH=300

# All sessions of OpenVidu will try to force this codec. If OPENVIDU_STREAMS_ALLOW_TRANSCODING=true
# when a codec can not be forced, transcoding will be allowed
# Values: VP8, H264, NONE
# Default value is VP8
# OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=VP8

# Allow transcoding if codec specified in OPENVIDU_STREAMS_FORCED_VIDEO_CODEC can not be applied
# Values: true | false
# Default value is false
# OPENVIDU_STREAMS_ALLOW_TRANSCODING=false

# true to enable OpenVidu Webhook service. false' otherwise
# Values: true | false
OPENVIDU_WEBHOOK=false

# HTTP endpoint where OpenVidu Server will send Webhook HTTP POST messages
# Must be a valid URL: http(s)://ENDPOINT
#OPENVIDU_WEBHOOK_ENDPOINT=

# List of headers that OpenVidu Webhook service will attach to HTTP POST messages
#OPENVIDU_WEBHOOK_HEADERS=

# List of events that will be sent by OpenVidu Webhook service
# Default value is all available events
OPENVIDU_WEBHOOK_EVENTS=[sessionCreated,sessionDestroyed,participantJoined,participantLeft,webrtcConnectionCreated,webrtcConnectionDestroyed,recordingStatusChanged,filterEventDispatched,mediaNodeStatusChanged,nodeCrashed]

# How often the garbage collector of non active sessions runs.
# This helps cleaning up sessions that have been initialized through
# REST API (and maybe tokens have been created for them) but have had no users connected.
# Default to 900s (15 mins). 0 to disable non active sessions garbage collector
OPENVIDU_SESSIONS_GARBAGE_INTERVAL=900

# Minimum time in seconds that a non active session must have been in existence
# for the garbage collector of non active sessions to remove it. Default to 3600s (1 hour).
# If non active sessions garbage collector is disabled
# (property 'OPENVIDU_SESSIONS_GARBAGE_INTERVAL' to 0) this property is ignored
OPENVIDU_SESSIONS_GARBAGE_THRESHOLD=3600

# Call Detail Record enabled
# Whether to enable Call Detail Record or not
# Values: true | false
OPENVIDU_CDR=false

# Path where the cdr log files are hosted
OPENVIDU_CDR_PATH=/opt/openvidu/cdr

# Kurento Media Server image
# --------------------------
# Docker hub kurento media server: https://hub.docker.com/r/kurento/kurento-media-server
# Uncomment the next line and define this variable with KMS image that you want use
# KMS_IMAGE=kurento/kurento-media-server:6.16.0

# Kurento Media Server Level logs
# -------------------------------
# Uncomment the next line and define this variable to change
# the verbosity level of the logs of KMS
# Documentation: https://doc-kurento.readthedocs.io/en/stable/features/logging.html
# KMS_DOCKER_ENV_GST_DEBUG=

# Openvidu Server Level logs
# --------------------------
# Uncomment the next line and define this variable to change
# the verbosity level of the logs of Openvidu Service
# RECOMENDED VALUES: INFO for normal logs DEBUG for more verbose logs
# OV_CE_DEBUG_LEVEL=INFO

# Java Options
# --------------------------
# Uncomment the next line and define this to add
# options to java command
# Documentation: https://docs.oracle.com/cd/E37116_01/install.111210/e23737/configuring_jvm.htm#OUDIG00058
# JAVA_OPTIONS=-Xms2048m -Xmx4096m -Duser.timezone=UTC

docker-compose.override.yml为

version: '3.1'

services:
    # --------------------------------------------------------------
    #
    #   Change this if your want use your own application.
    #   It's very important expose your application in port 5442
    #   and use the http protocol.
    #
    #   Default Application
    #
    #   Openvidu-Call Version: 2.20.0
    #
    # --------------------------------------------------------------
    app:
        image: openvidu/openvidu-call:2.20.0
        restart: on-failure
        network_mode: host
        environment:
            - SERVER_PORT=5442
            - OPENVIDU_URL=http://localhost:5443
            - OPENVIDU_SECRET=${OPENVIDU_SECRET}
            - CALL_OPENVIDU_CERTTYPE=${CERTIFICATE_TYPE}
        logging:
            options:
                max-size: "${DOCKER_LOGS_MAX_SIZE:-100M}"

docker-compose.yml为

# ------------------------------------------------------------------------------
#
#    DO NOT MODIFY THIS FILE !!!
#
#    Configuration properties should be specified in .env file
#
#    Application based on OpenVidu should be specified in
#    docker-compose.override.yml file
#
#    This docker-compose file coordinates all services of OpenVidu CE Platform
#
#    This file will be overridden when update OpenVidu Platform
#
#    Openvidu Version: 2.20.0
#
#    Installation Mode: On Premises
#
# ------------------------------------------------------------------------------

version: '3.1'

services:

    openvidu-server:
        image: openvidu/openvidu-server:2.20.0
        restart: on-failure
        network_mode: host
        entrypoint: ['/usr/local/bin/entrypoint.sh']
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - ${OPENVIDU_RECORDING_PATH}:${OPENVIDU_RECORDING_PATH}
            - ${OPENVIDU_RECORDING_CUSTOM_LAYOUT}:${OPENVIDU_RECORDING_CUSTOM_LAYOUT}
            - ${OPENVIDU_CDR_PATH}:${OPENVIDU_CDR_PATH}
        env_file:
            - .env
        environment:
            - SERVER_SSL_ENABLED=false
            - SERVER_PORT=5443
            - KMS_URIS=["ws://localhost:8888/kurento"]
            - COTURN_REDIS_IP=127.0.0.1
            - COTURN_REDIS_PASSWORD=${OPENVIDU_SECRET}
            - COTURN_IP=${COTURN_IP:-auto-ipv4}
        logging:
            options:
                max-size: "${DOCKER_LOGS_MAX_SIZE:-100M}"

    kms:
        image: ${KMS_IMAGE:-kurento/kurento-media-server:6.16.0}
        restart: always
        network_mode: host
        ulimits:
          core: -1
        volumes:
            - /opt/openvidu/kms-crashes:/opt/openvidu/kms-crashes
            - ${OPENVIDU_RECORDING_PATH}:${OPENVIDU_RECORDING_PATH}
            - /opt/openvidu/kurento-logs:/opt/openvidu/kurento-logs
        environment:
            - KMS_MIN_PORT=40000
            - KMS_MAX_PORT=57000
            - GST_DEBUG=${KMS_DOCKER_ENV_GST_DEBUG:-}
            - KURENTO_LOG_FILE_SIZE=${KMS_DOCKER_ENV_KURENTO_LOG_FILE_SIZE:-100}
            - KURENTO_LOGS_PATH=/opt/openvidu/kurento-logs
        logging:
            options:
                max-size: "${DOCKER_LOGS_MAX_SIZE:-100M}"

    redis:
        image: openvidu/openvidu-redis:3.0.0
        restart: always
        network_mode: host
        environment:
            - REDIS_PASSWORD=${OPENVIDU_SECRET}
        logging:
            options:
                max-size: "${DOCKER_LOGS_MAX_SIZE:-100M}"

    coturn:
        image: openvidu/openvidu-coturn:5.0.0
        restart: on-failure
        network_mode: host
        environment:
            - REDIS_IP=127.0.0.1
            - DB_NAME=0
            - DB_PASSWORD=${OPENVIDU_SECRET}
        command:
            - --log-file=stdout
            - --listening-port=3478
            - --fingerprint
            - --lt-cred-mech
            - --min-port=57001
            - --max-port=65535
            - --realm=openvidu
            - --verbose
        logging:
            options:
                max-size: "${DOCKER_LOGS_MAX_SIZE:-100M}"

    nginx:
        image: openvidu/openvidu-proxy:7.0.0
        restart: on-failure
        network_mode: host
        volumes:
            - ./certificates:/etc/letsencrypt
            - ./owncert:/owncert
            - ./custom-nginx-vhosts:/etc/nginx/vhost.d/
            - ${OPENVIDU_RECORDING_CUSTOM_LAYOUT}:/opt/openvidu/custom-layout
        environment:
            - DOMAIN_OR_PUBLIC_IP=${DOMAIN_OR_PUBLIC_IP}
            - CERTIFICATE_TYPE=${CERTIFICATE_TYPE}
            - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
            - PROXY_HTTP_PORT=${HTTP_PORT:-}
            - PROXY_HTTPS_PORT=${HTTPS_PORT:-}
            - PROXY_HTTPS_PROTOCOLS=${HTTPS_PROTOCOLS:-}
            - PROXY_HTTPS_CIPHERS=${HTTPS_CIPHERS:-}
            - PROXY_HTTPS_HSTS=${HTTPS_HSTS:-}
            - ALLOWED_ACCESS_TO_DASHBOARD=${ALLOWED_ACCESS_TO_DASHBOARD:-}
            - ALLOWED_ACCESS_TO_RESTAPI=${ALLOWED_ACCESS_TO_RESTAPI:-}
            - PROXY_MODE=CE
            - WITH_APP=true
            - SUPPORT_DEPRECATED_API=${SUPPORT_DEPRECATED_API:-true}
            - REDIRECT_WWW=${REDIRECT_WWW:-false}
            - WORKER_CONNECTIONS=${WORKER_CONNECTIONS:-10240}
            - PUBLIC_IP=${PROXY_PUBLIC_IP:-auto-ipv4}
        logging:
            options:
                max-size: "${DOCKER_LOGS_MAX_SIZE:-100M}"

openvidu为

#!/bin/bash

upgrade_ov() {
  UPGRADE_SCRIPT_URL="https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/install_openvidu_OVVERSION.sh"
  HTTP_STATUS=$(curl -s -o /dev/null -I -w "%{http_code}" ${UPGRADE_SCRIPT_URL//OVVERSION/$1})

  printf "  => Upgrading OpenVidu CE to '%s' version" "$1"

  if [ "$HTTP_STATUS" == "200" ]; then
    printf "\n    => Downloading and upgrading new version"
    printf "\n"

    curl --silent ${UPGRADE_SCRIPT_URL//OVVERSION/$1} | bash -s upgrade
  else
     printf "\n     =======¡ERROR!======="
     printf "\n     OpenVidu CE Version '%s' not exist" "$1"
     printf "\n"
     exit 0
  fi
}

collect_basic_information() {
  LINUX_VERSION=$(lsb_release -d)
  DOCKER_PS=$(docker ps)
  DOCKER_VERSION=$(docker version --format '{{.Server.Version}}')
  DOCKER_COMPOSE_VERSION=$(docker-compose version --short)
  OV_FOLDER="${PWD}"
  OV_VERSION=$(grep 'Openvidu Version:' "${OV_FOLDER}/docker-compose.yml" | awk '{ print $4 }')
  CONTAINERS=$(docker ps | awk '{if(NR>1) print $NF}')

  if [ -n "$(grep -E '^        image: openvidu/openvidu-call:.*$' "${OV_FOLDER}/docker-compose.override.yml" | tr -d '[:space:]')" ]; then
    OV_CALL_VERSION=$(grep -E 'Openvidu-Call Version:' "${OV_FOLDER}/docker-compose.override.yml" | awk '{ print $4 }')
  fi
  [ -z "${OV_CALL_VERSION}" ] && OV_CALL_VERSION="No present"

  OV_TYPE_INSTALLATION=$(grep 'Installation Mode:' "${OV_FOLDER}/docker-compose.yml" | awk '{ print $4,$5 }')
  TREE_OV_DIRECTORY=$(find "." | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/")
}

version_ov() {
  collect_basic_information

  printf '\nOpenvidu Information:'
  printf '\n'
  printf '\n  Installation Type: %s' "${OV_TYPE_INSTALLATION}"
  printf '\n  Openvidu Version: %s' "${OV_VERSION}"
  printf '\n  Openvidu Call Version: %s' "${OV_CALL_VERSION}"
  printf '\n'
  printf '\nSystem Information:'
  printf '\n'
  printf '\n  Linux Version:'
  printf '\n    - %s' "${LINUX_VERSION}"
  printf '\n  Docker Version: %s' "${DOCKER_VERSION}"
  printf '\n  Docker Compose Version: %s' "${DOCKER_COMPOSE_VERSION}"
  printf '\n'
  printf '\nInstallation Information:'
  printf '\n'
  printf '\n  Installation Folder: %s' "${OV_FOLDER}"
  printf '\n  Installation Folder Tree:'
  printf '\n%s' "$(echo "${TREE_OV_DIRECTORY}" | sed -e 's/.//' -e ':a' -e 'N;$!ba' -e 's/\n/\n\t/g')"
  printf '\n'
  printf '\nDocker Running Services:'
  printf '\n'
  printf '\n  %s' "$(echo "${DOCKER_PS}" | sed -e ':a' -e 'N;$!ba' -e 's/\n/\n\t/g')"
  printf '\n'
}

generate_report() {
  collect_basic_information

  REPORT_CREATION_DATE=$(date +"%d-%m-%Y")
  REPORT_CREATION_TIME=$(date +"%H:%M:%S")
  REPORT_NAME="openvidu-report-${REPORT_CREATION_DATE}-$(date +"%H-%M").txt"
  REPORT_OUTPUT="${OV_FOLDER}/${REPORT_NAME}"

  {
    printf "\n  ======================================="
    printf "\n  =         REPORT INFORMATION          ="
    printf "\n  ======================================="
    printf '\n'
    printf '\n  Creation Date: %s' "${REPORT_CREATION_DATE}"
    printf '\n  Creation Time: %s' "${REPORT_CREATION_TIME}"
    printf '\n'
    printf "\n  ======================================="
    printf "\n  =       OPENVIDU INFORMATION          ="
    printf "\n  ======================================="
    printf '\n'
    printf '\n  Installation Type: %s' "${OV_TYPE_INSTALLATION}"
    printf '\n  Openvidu Version: %s' "${OV_VERSION}"
    printf '\n  Openvidu Call Version: %s' "${OV_CALL_VERSION}"
    printf '\n'
    printf "\n  ======================================="
    printf "\n  =         SYSTEM INFORMATION          ="
    printf "\n  ======================================="
    printf '\n'
    printf '\n  Linux Version:'
    printf '\n    - %s' "${LINUX_VERSION}"
    printf '\n  Docker Version: %s' "${DOCKER_VERSION}"
    printf '\n  Docker Compose Version: %s' "${DOCKER_COMPOSE_VERSION}"
    printf '\n'
    printf "\n  ======================================="
    printf "\n  =     INSTALLATION INFORMATION        ="
    printf "\n  ======================================="
    printf '\n'
    printf '\n  Installation Folder: %s' "${OV_FOLDER}"
    printf '\n  Installation Folder Tree:'
    printf '\n%s' "$(echo "${TREE_OV_DIRECTORY}" | sed -e 's/.//' -e ':a' -e 'N;$!ba' -e 's/\n/\n\t/g')"
    printf '\n'
    printf "\n  ======================================="
    printf "\n  =      DOCKER RUNNING SERVICES        ="
    printf "\n  ======================================="
    printf '\n'
    printf '\n  %s' "$(echo "${DOCKER_PS}" | sed -e ':a' -e 'N;$!ba' -e 's/\n/\n\t/g')"
    printf '\n'
    printf "\n  ======================================="
    printf "\n  =        CONFIGURATION FILES          ="
    printf "\n  ======================================="
    printf '\n'
    printf '\n  ================ .env ================='
    printf '\n'
    printf '\n'

    cat < "${OV_FOLDER}/.env" | sed -r -e "s/OPENVIDU_SECRET=.+/OPENVIDU_SECRET=****/"

    printf '\n'
    printf '\n  ========= docker-compose.yml =========='
    printf '\n'
    printf '\n'

    cat "${OV_FOLDER}/docker-compose.yml"

    printf '\n'
    printf '\n  ==== docker-compose.override.yml ===='
    printf '\n'
    printf '\n'

    if [ -f "${OV_FOLDER}/docker-compose.override.yml" ]; then
      cat < "${OV_FOLDER}/docker-compose.override.yml"
    else
      printf '\n  The docker-compose.override.yml file is not present'
    fi

    printf '\n'
    printf '\n'
    printf "\n  ======================================="
    printf "\n  =                LOGS                 ="
    printf "\n  ======================================="

    for CONTAINER in $CONTAINERS
    do
      printf '\n'
      printf "\n  ---------------------------------------"
      printf "\n  %s" "$CONTAINER"
      printf "\n  ---------------------------------------"
      printf '\n'
      docker logs "$CONTAINER"
      printf "\n  ---------------------------------------"
      printf '\n'
      printf '\n'
    done

    printf '\n'
    printf "\n  ---------------------------------------"
    printf "\n  KMS"
    printf "\n  ---------------------------------------"
    printf '\n'
    kurento_logs
    printf "\n  ---------------------------------------"
    printf '\n'
    printf '\n'

    printf "\n  ======================================="
    printf "\n  =       CONTAINER ENVS VARIABLES      ="
    printf "\n  ======================================="

    for CONTAINER in $CONTAINERS
    do
      printf '\n'
      printf "\n  ======================================="
      printf "\n  %s" "$CONTAINER"
      printf "\n  ---------------------------------------"
      printf '\n'
      docker exec "$CONTAINER" env
      printf "\n  ---------------------------------------"
      printf '\n'
      printf '\n'
    done

  } >> "${REPORT_OUTPUT}" 2>&1

  printf "\n  Generation of the report completed with success"
  printf "\n  You can get your report at path '%s'" "${REPORT_OUTPUT}"
  printf "\n"
}

usage() {
    printf "Usage: \n\t openvidu [command]"
    printf "\n\nAvailable Commands:"
    printf "\n\tstart\t\t\tStart all services"
    printf "\n\tstop\t\t\tStop all services"
    printf "\n\trestart\t\t\tRestart all stopped and running services"
    printf "\n\tlogs [-f]\t\tShow openvidu logs."
    printf "\n\tkms-logs [-f]\t\tShow kms logs"
    printf "\n\tupgrade\t\t\tUpgrade to the latest Openvidu version"
    printf "\n\tupgrade [version]\tUpgrade to the specific Openvidu version"
    printf "\n\tversion\t\t\tShow version of Openvidu Server"
    printf "\n\treport\t\t\tGenerate a report with the current status of Openvidu"
    printf "\n\thelp\t\t\tShow help for openvidu command"
    printf "\n"
}

kurento_logs() {
  if [[ "$1" == "-f" ]]; then
    tail -f /opt/openvidu/kurento-logs/*.log
  else
    cat /opt/openvidu/kurento-logs/*.log
  fi
}

case $1 in
  start)
    docker-compose up -d
    docker-compose logs -f openvidu-server
    ;;

  stop)
    docker-compose down
    ;;

  restart)
    docker-compose down
    docker-compose up -d
    docker-compose logs -f openvidu-server
    ;;

  logs)
    case $2 in
      "-f")
        docker-compose logs -f openvidu-server
        ;;
      *)
        docker-compose logs openvidu-server
        ;;
    esac
    ;;

  kms-logs)
    kurento_logs "$2"
    ;;

  upgrade)
    if [ -z "$2" ]; then
      UPGRADE_VERSION="latest"
    else
      UPGRADE_VERSION="$2"
    fi

    read -r -p "  You're about to update OpenVidu CE to '${UPGRADE_VERSION}' version. Are you sure? [y/N]: " response
    case "$response" in
      [yY][eE][sS]|[yY])
        upgrade_ov "${UPGRADE_VERSION}"
        ;;
      *)
        exit 0
        ;;
    esac
    ;;

  version)
    version_ov
    ;;

  report)
    read -r -p "  You are about to generate a report on the current status of Openvidu, this may take some time. Do you want to continue? [y/N]: " response
    case "$response" in
      [yY][eE][sS]|[yY])
        generate_report
        ;;
      *)
        exit 0
        ;;
    esac
    ;;

  *)
    usage
    ;;
esac

设置.env文件中的DOMAIN_OR_PUBLIC_IP和OPENVIDU_SECRET。然后执行

sudo ./openvidu start

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

openvidu部署 的相关文章

  • [Mac 基础知识]:用Time Machine 恢复mac系统

    如果您使用 Time Machine 来备份 Mac xff0c 则在系统或启动磁盘损坏时可以恢复系统 Important 使用 Time Machine 备份将您的系统恢复到该备份的源 Mac 若 要将信息传输到新 Mac xff0c 请
  • jetson-tx2-4g ubuntu18系统设置中desktop sharing 无法打开的问题

    1 系统设置中desktop sharing无法打开需要进行以下几步 xff1a sudo apt get install vino dconf editor dconf write org gnome desktop remote acc
  • ubuntu18.04安装xrdp过程

    一 安装桌面环境 以具有 sudo 权限的用户身份键入以下命令 xff0c 以在服务器上安装 Xfce xff1a sudo apt update sudo apt install xfce4 xfce4 goodies xorg dbus
  • 瑞芯微RV1126/1109开发流程之模型转换

    1 环境搭建 xff08 PC端ubuntu16 04搭建rknn环境 xff09 xff08 1 xff09 安装anaconda环境 xff08 为了便于管理自己的环境建议安装 xff0c 安装步骤请自行搜索 xff0c 本人安装ana
  • 瑞芯微RV1126/1109开发流程之驱动升级

    1 1126硬件参数读取 xff08 1 xff09 CPU温度读取 46300和47100分别代表46 3 47 1 xff08 2 xff09 查看1126的NPU xff08 3 xff09 查询NPU驱动版本 dmesg grep
  • 如何在 ubuntu 安装并配置Go?

    如何在 ubuntu 安装并配置Go xff1f 虽然安装和配置go很简单 xff0c 但是很多初学者在第一次安装go环境时会遇到各种坑 这篇博客完整演示一次如何在ubuntu上安装和配置golang 第一步 xff0c 查看系统版本 xf
  • 瑞芯微RV1126/1109开发流程之yolov5部署(c++版本)

    1 ubuntu上安装rv1126交叉编译工具链 方式一 xff1a xff08 1 xff09 下载交叉编译工具 交叉编译器概念 xff1a 交叉编译器可以使我们在主机上编译出可以在嵌入式设备上运行的程序 下载地址 xff1a Downl
  • 瑞芯微RV1126/1109开发流程之资料收藏

    RKMedia Firefly Wiki https blog csdn net u013171226 category 11410227 html目前该博主已经建立专栏 RV1109 RV1126系列 3 RV1109 1126 RKNN
  • 瑞芯微RV1126/1109开发流程之opencv交叉编译

    1 下载opencv并解压 这里的opencv版本是我一直用者的opencv3 4 0 没有opencv的可以到这里 xff08 https opencv org releases page 5 xff09 下载 2 创建build和ins
  • yolov5目标检测算法研究之参考资料

    CSP网络架构 深度学习之CSPNet分析 tt丫的博客 CSDN博客 cspnet结构 深度学习入门小菜鸟 xff0c 希望像做笔记记录自己学的东西 xff0c 也希望能帮助到同样入门的人 xff0c 更希望大佬们帮忙纠错啦 侵权立删 目
  • pytorch统计模型参数量并输出

    有时候需要统计我们自己构建的模型参数 与baseline的网络比较 统计神经网络模型参数 方式一 def get parameter number net total num 61 sum p numel for p in net para
  • TCP传输过程中,客户端异常退出导致服务端send函数崩溃

    在linux下编写TCP socket程序时 xff0c 如果客户端突然退出 xff0c 导致连接中断 xff0c 这个时候服务端如果继续调用send函数发送数据的话 xff0c 会导致整个进程退出 xff0c 这是我们不愿看到的 xff0
  • linux socket编程 close函数详解

    int close int fd close 函数存在于函数库unistd h函数库中 xff1b close 函数用于释放系统分配给套接字的资源 xff0c 该函数即文件操作中常用的close函数 参数fd为需要关闭的套接字文件描述符 x
  • 瑞芯微RV1126/1109开发流程之json交叉编译

    1 下载json源码 下载json源码地址https github com open source parsers jsoncpp https github com open source parsers jsoncpp 本次安装下载jso
  • 瑞芯微RV1126/1109开发流程之redis交叉编译

    1 下载redis源码 下载json源码地址 Releases redis redis GitHub 本次安装下载json版本为redis 5 0 10 tar gz 2 解压 下载下来后解压 tar zxvf redis 5 0 10 t
  • 瑞芯微RV1126/1109开发流程之JDK安装

    因本人在基于rv1126上开发的项目需要用到java xff0c 于是需要在该平台上安装JDK xff0c 在安装过程中遇到些错误 xff1b 边缘视频计算模组均是基于ARM开发的 xff0c 但是ARM的硬件架构类似CPU架构也分32位和
  • kvm GPU直通(kvm GPU passthrough)

    感兴趣的可以站内私信我或直接打开链接显卡虚拟化方案之GPU透传 三 实战篇 为了方便对服务器进行自动管理 我们需要对硬件进行虚拟化 对于显卡而言 Nvidia有专门支持GPU虚拟化的显卡 比如GRID GPU系列 以NVIDIA GRID

随机推荐