mirror of
https://github.com/jitsi/docker-jitsi-meet.git
synced 2026-04-02 15:51:05 +02:00
jibri: add autoscaler-sidecar service support (#1562)
This commit is contained in:
parent
57a7c22e1d
commit
0569bce51b
@ -10,9 +10,17 @@ services:
|
||||
cap_add:
|
||||
- SYS_ADMIN
|
||||
environment:
|
||||
- AUTOSCALER_SIDECAR_KEY_FILE
|
||||
- AUTOSCALER_SIDECAR_KEY_ID
|
||||
- AUTOSCALER_SIDECAR_GROUP_NAME
|
||||
- AUTOSCALER_SIDECAR_INSTANCE_ID
|
||||
- AUTOSCALER_SIDECAR_PORT
|
||||
- AUTOSCALER_SIDECAR_REGION
|
||||
- AUTOSCALER_URL
|
||||
- CHROMIUM_FLAGS
|
||||
- DISPLAY=:0
|
||||
- ENABLE_STATS_D
|
||||
- JIBRI_WEBHOOK_SUBSCRIBERS
|
||||
- JIBRI_HTTP_API_EXTERNAL_PORT
|
||||
- JIBRI_HTTP_API_INTERNAL_PORT
|
||||
- JIBRI_RECORDING_RESOLUTION
|
||||
@ -25,6 +33,7 @@ services:
|
||||
- JIBRI_RECORDING_DIR
|
||||
- JIBRI_FINALIZE_RECORDING_SCRIPT_PATH
|
||||
- JIBRI_STRIP_DOMAIN_JID
|
||||
- LOCAL_ADDRESS
|
||||
- PUBLIC_URL
|
||||
- TZ
|
||||
- XMPP_AUTH_DOMAIN
|
||||
|
||||
@ -18,7 +18,7 @@ ARG CHROMEDRIVER_MAJOR_RELEASE=113
|
||||
COPY rootfs/ /
|
||||
|
||||
RUN apt-dpkg-wrap apt-get update && \
|
||||
apt-dpkg-wrap apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" jibri libgl1-mesa-dri procps jitsi-upload-integrations jq pulseaudio dbus dbus-x11 rtkit unzip && \
|
||||
apt-dpkg-wrap apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" jibri libgl1-mesa-dri procps jitsi-upload-integrations jitsi-autoscaler-sidecar jq pulseaudio dbus dbus-x11 rtkit unzip && \
|
||||
/usr/bin/install-chrome.sh && \
|
||||
apt-cleanup && \
|
||||
adduser jibri rtkit
|
||||
|
||||
14
jibri/rootfs/defaults/autoscaler-sidecar.config
Normal file
14
jibri/rootfs/defaults/autoscaler-sidecar.config
Normal file
@ -0,0 +1,14 @@
|
||||
{{ $JIBRI_HTTP_API_EXTERNAL_PORT := .Env.JIBRI_HTTP_API_EXTERNAL_PORT | default "2222" -}}
|
||||
export PORT={{ .Env.AUTOSCALER_SIDECAR_PORT }}
|
||||
export GRACEFUL_SHUTDOWN_SCRIPT="/opt/jitsi/jibri/wait_graceful_shutdown.sh"
|
||||
export TERMINATE_SCRIPT="/opt/jitsi/jibri/shutdown.sh"
|
||||
export ENABLE_REPORT_STATS=true
|
||||
export POLLING_URL="{{ .Env.AUTOSCALER_URL }}/sidecar/poll"
|
||||
export STATUS_URL="{{ .Env.AUTOSCALER_URL }}/sidecar/status"
|
||||
export STATS_RETRIEVE_URL="http://localhost:{{ $JIBRI_HTTP_API_EXTERNAL_PORT }}/jibri/api/v1.0/health"
|
||||
export STATS_REPORT_URL="{{ .Env.AUTOSCALER_URL }}/sidecar/stats"
|
||||
export ASAP_SIGNING_KEY_FILE="{{ .Env.AUTOSCALER_SIDECAR_KEY_FILE }}"
|
||||
export ASAP_JWT_KID="{{ .Env.AUTOSCALER_SIDECAR_KEY_ID }}"
|
||||
export INSTANCE_TYPE="jibri"
|
||||
export INSTANCE_ID="{{ .Env.AUTOSCALER_SIDECAR_INSTANCE_ID }}"
|
||||
export INSTANCE_METADATA='{"environment":"{{ .Env.XMPP_ENV_NAME }}","region":"{{ .Env.AUTOSCALER_SIDECAR_REGION }}","group":"{{ .Env.AUTOSCALER_SIDECAR_GROUP_NAME }}","name":"{{ .Env.JIBRI_INSTANCE_ID }}","version":"{{ .Env.JIBRI_VERSION }}","privateIp":"{{ .Env.LOCAL_ADDRESS }}"}'
|
||||
@ -106,7 +106,10 @@ jibri {
|
||||
finalize-script = "{{ .Env.JIBRI_FINALIZE_RECORDING_SCRIPT_PATH }}"
|
||||
{{ end -}}
|
||||
}
|
||||
|
||||
{{ if .Env.JIBRI_WEBHOOK_SUBSCRIBERS -}}
|
||||
webhook {
|
||||
subscribers = [{{ range $index, $element := splitList "," .Env.JIBRI_WEBHOOK_SUBSCRIBERS }}{{ if gt $index 0}},{{ end }}"{{ $element }}"{{ end }}]
|
||||
}{{ end }}
|
||||
ffmpeg {
|
||||
resolution = "{{ $JIBRI_RECORDING_RESOLUTION }}"
|
||||
// The audio source that will be used to capture audio on Linux
|
||||
|
||||
@ -30,6 +30,37 @@ fi
|
||||
# set random jibri nickname for the instance if is not set
|
||||
[ -z "${JIBRI_INSTANCE_ID}" ] && export JIBRI_INSTANCE_ID="jibri-$(date +%N)"
|
||||
|
||||
# check for AUTOSCALER_URL, AUTOSCALER_SIDECAR_KEY_FILE and AUTOSCALER_SIDECAR_KEY_ID as indicator that sidecar should be enabled
|
||||
if [ -n "$AUTOSCALER_URL" ]; then
|
||||
if [ -z "$AUTOSCALER_SIDECAR_KEY_FILE" ]; then
|
||||
export AUTOSCALER_SIDECAR_KEY_FILE="/etc/jitsi/autoscaler-sidecar/asap.pem"
|
||||
fi
|
||||
if [ -z "$AUTOSCALER_SIDECAR_KEY_ID" ]; then
|
||||
# assume key id is equal to the base real path of the key file minus .pem
|
||||
export AUTOSCALER_SIDECAR_KEY_ID="$(basename "$(realpath "$AUTOSCALER_SIDECAR_KEY_FILE")" | tr -d '.pem')"
|
||||
fi
|
||||
|
||||
if [ -f "$AUTOSCALER_SIDECAR_KEY_FILE" ]; then
|
||||
echo "AUTOSCALER_URL found, enabling autoscaler sidecar"
|
||||
|
||||
export JIBRI_VERSION="$(dpkg -s jibri | grep Version | awk '{print $2}' | sed 's/..$//')"
|
||||
|
||||
[ -z "$AUTOSCALER_SIDECAR_PORT" ] && export AUTOSCALER_SIDECAR_PORT="6000"
|
||||
[ -z "$JIBRI_WEBHOOK_SUBSCRIBERS" ] && export JIBRI_WEBHOOK_SUBSCRIBERS="http://localhost:$AUTOSCALER_SIDECAR_PORT/hook"
|
||||
[ -z "$AUTOSCALER_SIDECAR_INSTANCE_ID" ] && export AUTOSCALER_SIDECAR_INSTANCE_ID="$JIBRI_INSTANCE_ID"
|
||||
[ -z "$AUTOSCALER_SIDECAR_REGION" ] && export AUTOSCALER_SIDECAR_REGION="docker"
|
||||
[ -z "$AUTOSCALER_SIDECAR_GROUP_NAME" ] && export AUTOSCALER_SIDECAR_GROUP_NAME="docker-jibri"
|
||||
[ -z "$LOCAL_ADDRESS" ] && export LOCAL_ADDRESS="$(ip route get 1 | grep -oP '(?<=src ).*' | awk '{ print $1 '})"
|
||||
|
||||
mkdir -p /etc/jitsi/autoscaler-sidecar
|
||||
tpl /defaults/autoscaler-sidecar.config > /etc/jitsi/autoscaler-sidecar/config
|
||||
else
|
||||
echo "No key file at $AUTOSCALER_SIDECAR_KEY_FILE, leaving autoscaler sidecar disabled"
|
||||
fi
|
||||
else
|
||||
echo "No AUTOSCALER_URL defined, leaving autoscaler sidecar disabled"
|
||||
fi
|
||||
|
||||
# always recreate configs
|
||||
tpl /defaults/jibri.conf > /etc/jitsi/jibri/jibri.conf
|
||||
tpl /defaults/logging.properties > /etc/jitsi/jibri/logging.properties
|
||||
|
||||
10
jibri/rootfs/etc/services.d/50-autoscaler-sidecar/run
Normal file
10
jibri/rootfs/etc/services.d/50-autoscaler-sidecar/run
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
if [[ -n "$AUTOSCALER_URL" ]] && [[ -f "/etc/jitsi/autoscaler-sidecar/config" ]]; then
|
||||
DAEMON="/usr/bin/node /usr/share/jitsi-autoscaler-sidecar/app.js"
|
||||
exec s6-setuidgid autoscaler-sidecar /bin/bash -c ". /etc/jitsi/autoscaler-sidecar/config && exec $DAEMON"
|
||||
else
|
||||
# if autoscaler-sidecar should not be started,
|
||||
# prevent s6 from restarting this script again and again
|
||||
s6-svc -O /var/run/s6/services/50-autoscaler-sidecar
|
||||
fi
|
||||
Loading…
x
Reference in New Issue
Block a user