Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
recording: separate container for processing
Browse files Browse the repository at this point in the history
  • Loading branch information
alangecker committed Jul 27, 2020
1 parent 311e0fb commit 76faab0
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 67 deletions.
13 changes: 13 additions & 0 deletions docker-compose.recording.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.6'
services:
recordings-process:
build: mod/recordings-process
environment:
DOMAIN: ${DOMAIN}
volumes:
- bigbluebutton:/var/bigbluebutton
- vol-freeswitch:/var/freeswitch/meetings
- vol-kurento:/var/kurento
networks:
bbb-net:
ipv4_address: 10.7.7.16
12 changes: 1 addition & 11 deletions mod/core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ MAINTAINER ffdixon@bigbluebutton.org
# TODO:
# - separate bbb-apps into an own container
# - separate bbb-web
# - remove systemd

ENV DEBIAN_FRONTEND noninteractive
ENV container docker
Expand Down Expand Up @@ -39,8 +38,7 @@ RUN equivs-control redis-server.control \

RUN apt-get update && apt-get install -y bbb-web \
bbb-fsesl-akka bbb-apps-akka bbb-transcode-akka bbb-apps \
bbb-apps-video bbb-apps-screenshare bbb-apps-video-broadcast \
bbb-record-core bbb-playback-presentation
bbb-apps-video bbb-apps-screenshare bbb-apps-video-broadcast

# -- avoid blocking java
# https://github.com/bigbluebutton/bigbluebutton/issues/8959
Expand All @@ -66,14 +64,6 @@ COPY bbb-apps-akka/application.conf /usr/share/bbb-apps-akka/conf/application.co
COPY bbb-fsesl-akka/application.conf /etc/bbb-fsesl-akka/application.conf
COPY bbb-transcode-akka/application.conf /etc/bbb-transcode-akka/application.conf
COPY web-run.sh /usr/share/bbb-web/run-prod.sh
COPY bbb-playback-presentation/presentation.yml /usr/local/bigbluebutton/core/scripts/
COPY bbb-playback-presentation/record-monitor.sh /usr/local/bin
RUN chmod +x /usr/local/bin/record-monitor.sh && \
mkdir -p /usr/src/bbb-playback-presentation && \
cp -r /var/bigbluebutton/playback/* /usr/src/bbb-src-playback

RUN wget -O /usr/local/bin/bbb-record https://raw.githubusercontent.com/bigbluebutton/bigbluebutton/develop/bigbluebutton-config/bin/bbb-record \
&& chmod +x /usr/local/bin/bbb-record

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY entrypoint.sh /entrypoint.sh
Expand Down
5 changes: 5 additions & 0 deletions mod/core/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
export LANG=en_US.UTF-8

# generate bbb folders
mkdir -p /var/bigbluebutton/events
mkdir -p /var/bigbluebutton/captions
mkdir -p /var/bigbluebutton/captions/inbox
mkdir -p /var/bigbluebutton/basic_stats
mkdir -p /var/bigbluebutton/recording/raw
mkdir -p /var/bigbluebutton/recording/process
mkdir -p /var/bigbluebutton/recording/publish
mkdir -p /var/bigbluebutton/recording/publish/presentation
mkdir -p /var/bigbluebutton/recording/status
mkdir -p /var/bigbluebutton/recording/status/recorded
mkdir -p /var/bigbluebutton/recording/status/archived
mkdir -p /var/bigbluebutton/recording/status/processed
Expand Down
55 changes: 0 additions & 55 deletions mod/core/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -42,58 +42,3 @@ stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0

[program:rap-archive-worker]
command=/usr/local/bin/prefix-log /usr/local/bin/record-monitor.sh recorded
user=bigbluebutton
directory=/usr/local/bigbluebutton/core/scripts
autostart=true
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0

[program:rap-events-worker]
command=/usr/local/bin/prefix-log /usr/local/bin/record-monitor.sh ended
user=bigbluebutton
directory=/usr/local/bigbluebutton/core/scripts
autostart=true
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0

[program:rap-process-worker]
command=/usr/local/bin/prefix-log /usr/local/bin/record-monitor.sh sanity
user=bigbluebutton
directory=/usr/local/bigbluebutton/core/scripts
autostart=true
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0

[program:rap-publish-worker]
command=/usr/local/bin/prefix-log /usr/local/bin/record-monitor.sh processed
user=bigbluebutton
directory=/usr/local/bigbluebutton/core/scripts
autostart=true
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0

[program:rap-sanity-worker]
command=/usr/local/bin/prefix-log /usr/local/bin/record-monitor.sh archived
user=bigbluebutton
directory=/usr/local/bigbluebutton/core/scripts
autostart=true
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0
2 changes: 1 addition & 1 deletion mod/nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENV TAG v2.2.20
# get bbb-playback-presentation web files
RUN mkdir /www \
&& cd /www \
&& svn checkout https://github.com/alangecker/bbb-packages/tags/$TAG/bbb-playback-presentation/data/var/bigbluebutton/playback/presentation/ \
&& svn checkout https://github.com/bigbluebutton/bigbluebutton/tags/$TAG/record-and-playback/presentation/playback/presentation/ \
&& rm -rf /www/presentation/.svn /www/presentation/0.*

COPY ./bbb /etc/nginx/bbb
Expand Down
83 changes: 83 additions & 0 deletions mod/recordings-process/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
FROM ruby:2.4-slim-buster

# install apt dependencies
RUN apt-get update && apt-get install -y \
wget \
subversion \
rsync \
build-essential \
libsystemd-dev \
python3 \
python3-pyinotify \
python3-lxml \
python3-icu \
ffmpeg \
poppler-utils \
imagemagick

# compile and install mkclean
RUN cd /tmp \
&& wget https://netcologne.dl.sourceforge.net/project/matroska/mkclean/mkclean-0.8.10.tar.bz2 \
&& tar -xf /tmp/mkclean-0.8.10.tar.bz2 \
&& cd /tmp/mkclean-0.8.10 \
&& sed -i 's/\r//g' ./mkclean/configure.compiled \
&& ./mkclean/configure.compiled \
&& make -C mkclean \
&& cp ./release/gcc_linux_x64/mkclean /usr/bin/mkclean \
&& rm -r /tmp/mkclean-0.8.10

# add dockerize
ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

RUN mkdir -p \
/usr/local/bigbluebutton \
/usr/local/bigbluebutton/core \
/etc/bigbluebutton \
/var/log/bigbluebutton \
/var/log/bigbluebutton/presentation

ENV TAG v2.2.20

# add bbb-record-core (lib, scripts and Gemfile)
RUN cd /usr/local/bigbluebutton/core \
&& svn checkout https://github.com/bigbluebutton/bigbluebutton/tags/$TAG/record-and-playback/core/lib \
&& svn checkout https://github.com/bigbluebutton/bigbluebutton/tags/$TAG/record-and-playback/core/scripts \
&& rm -rf /usr/local/bigbluebutton/core/*/.svn \
&& wget https://raw.githubusercontent.com/bigbluebutton/bigbluebutton/$TAG/record-and-playback/core/Gemfile.lock \
&& wget https://raw.githubusercontent.com/bigbluebutton/bigbluebutton/$TAG/record-and-playback/core/Gemfile


# add bbb-playback-presentation scripts
RUN cd /tmp \
&& svn checkout https://github.com/bigbluebutton/bigbluebutton/tags/$TAG/record-and-playback/presentation/scripts \
&& rsync -av /tmp/scripts/ /usr/local/bigbluebutton/core/scripts/ \
&& rm -rf /tmp/scripts

# install ruby dependencies
RUN cd /usr/local/bigbluebutton/core \
&& gem install builder \
&& gem install bundler \
&& /usr/local/bin/bundle

# add bbb-record with some adjustments so bbb-record works in this environment
RUN cd /usr/bin \
&& wget https://raw.githubusercontent.com/bigbluebutton/bigbluebutton/$TAG/bigbluebutton-config/bin/bbb-record \
&& chmod +x /usr/bin/bbb-record \
&& sed -i 's/^BBB_WEB.*/BBB_WEB=""/' /usr/bin/bbb-record \
&& sed -i 's/systemctl.*//' /usr/bin/bbb-record \
&& echo "BIGBLUEBUTTON_RELEASE=$TAG" > /etc/bigbluebutton/bigbluebutton-release \
&& touch /var/log/bigbluebutton/bbb-web.log

# create user
# the ID should matcht the one creating the files in `core`
RUN groupadd -g 998 bigbluebutton && useradd -m -u 998 -g bigbluebutton bigbluebutton

COPY bigbluebutton.yml /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml.tmpl
COPY log-collector.py /log-collector.py
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT dockerize \
-template /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml.tmpl:/usr/local/bigbluebutton/core/scripts/bigbluebutton.yml \
/entrypoint.sh
37 changes: 37 additions & 0 deletions mod/recordings-process/bigbluebutton.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
bbb_version: '2.1.0'
raw_audio_src: /var/freeswitch/meetings
raw_video_src: /usr/share/red5/webapps/video/streams
kurento_video_src: /var/kurento/recordings
kurento_screenshare_src: /var/kurento/screenshare
raw_screenshare_src: /usr/share/red5/webapps/screenshare/streams
raw_webrtc_deskshare_src: /usr/share/red5/webapps/video-broadcast/streams
raw_deskshare_src: /var/bigbluebutton/deskshare
raw_presentation_src: /var/bigbluebutton
notes_endpoint: http://etherpad:9001/p
# Specify the notes formats we archive
# txt, doc and odt are also supported
notes_formats:
- etherpad
- html
- pdf
redis_host: redis
redis_port: 6379
# Uncomment and set password if redis require it.
# redis_password: changeme

# For PRODUCTION
log_dir: /var/log/bigbluebutton
events_dir: /var/bigbluebutton/events
recording_dir: /var/bigbluebutton/recording
published_dir: /var/bigbluebutton/published
captions_dir: /var/bigbluebutton/captions
playback_host: {{ .Env.DOMAIN }}
playback_protocol: https

# For DEVELOPMENT
# This allows us to run the scripts manually
#scripts_dir: /home/ubuntu/dev/bigbluebutton/record-and-playback/core/scripts
#log_dir: /home/ubuntu/temp/log
#recording_dir: /home/ubuntu/temp/recording
#published_dir: /home/ubuntu/temp/published
#playback_host: meet.livingutopia.org
18 changes: 18 additions & 0 deletions mod/recordings-process/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# print all logs to stdout
python3 -u /log-collector.py &

cd /usr/local/bigbluebutton/core/scripts

while true; do
bundle exec ruby rap-archive-worker.rb
bundle exec ruby rap-sanity-worker.rb
bundle exec ruby rap-process-worker.rb
bundle exec ruby rap-publish-worker.rb

bundle exec ruby rap-caption-inbox.rb
bundle exec ruby rap-events-worker.rb

sleep 30s
done
45 changes: 45 additions & 0 deletions mod/recordings-process/log-collector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# this script sends all entries from different logfiles
# to stdout, so that they appear in the docker logs

import threading
import subprocess
import time
import pyinotify
import os
import re
import sys

log_dir = '/var/log/bigbluebutton'

def thread_function(name, filename):
f = subprocess.Popen(['tail','-F', '-n', '0', filename],\
stdout=subprocess.PIPE,stderr=subprocess.PIPE)
while True:
line = f.stdout.readline().decode('utf-8').strip()
if len(line):
print(name.ljust(10)+' |', line)
sys.stdout.flush()

def tail_file(name, filename):
x = threading.Thread(target=thread_function, args=(name, filename,))
x.start()


tail_file('rap-worker', log_dir+'/bbb-rap-worker.log')
tail_file('sanity', log_dir+'/sanity.log')
tail_file('publish', log_dir+'/post_publish.log')

class EventHandler(pyinotify.ProcessEvent):
def process_IN_CREATE(self, event):
filename = os.path.basename(event.pathname)
if re.match('^archive-.*\.log$', filename):
tail_file('archive', event.pathname)
elif re.match('^process-.*\.log$', filename):
tail_file('process', event.pathname)


wm = pyinotify.WatchManager()
handler = EventHandler()
notifier = pyinotify.Notifier(wm, handler)
wdd = wm.add_watch(log_dir, pyinotify.IN_CREATE, rec=True)
notifier.loop()
4 changes: 4 additions & 0 deletions scripts/compose
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ if [ "$ENABLE_GREENLIGHT" == true ]; then
COMPOSE_FILES="$COMPOSE_FILES -f docker-compose.greenlight.yml"
fi

if [ "$ENABLE_RECORDING" == true ]; then
COMPOSE_FILES="$COMPOSE_FILES -f docker-compose.recording.yml"
fi

docker-compose $COMPOSE_FILES $@

0 comments on commit 76faab0

Please sign in to comment.