Skip to content

Commit

Permalink
Merge pull request #94 from tochev/feature-use-dev-shm
Browse files Browse the repository at this point in the history
Use /dev/shm for chrome
  • Loading branch information
mtsonline committed Dec 11, 2020
2 parents 81bedcf + 060c9d1 commit b510a1a
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

## v1.0.0-beta7 ##

- (BACKWARD INCOMPATIBLE) use `/dev/shm/` for chrome unless `BROWSER_DISABLE_DEV_SHM_USAGE=false`; ACTION: make sure to add `shm_size=2gb` to your docker container
- new defaults for ffmpeg options
- ffmpeg options customizable via environment variables (see below for details)
- set default language for chromium to en-us
- made pulse audio more robust
-* removed alsa for better compatibility
- removed alsa for better compatibility
- made html5 client the default if not set in bbb server config
- fixed bug when chat was disabled in the meeting
- fixed typos and added informations to the docs / readme
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ You need to set some environment variables to run the container.
* FFMPEG_INPUT_THREAD_QUEUE_SIZE - `thread_queue_size` option to be passed to ffmpeg (Default: 1024)
* FFMPEG_STREAM_OPTIONS - ffmpeg options to use when streaming (bitrate/codec/...), see `stream.py` for default value
* FFMPEG_DOWNLOAD_OPTIONS - ffmpeg options to use when downloading, see `stream.py` for default value
* BROWSER_DISABLE_DEV_SHM_USAGE - whether to disable `/dev/shm` usage of the browser (default: false),
for use cases where available /dev/shm is very limited, note that setting this to true can result in disk trashing

### Starting liveStreaming
* wget -O docker-compose.yml https://raw.github.com/aau-zid/BigBlueButton-liveStreaming/1.0.0-beta.7/examples/docker-compose.yml.example
Expand Down
21 changes: 18 additions & 3 deletions chat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, argparse, time, logging, os, redis
import sys, argparse, time, subprocess, logging, os, redis
from bigbluebutton_api_python import BigBlueButton
from bigbluebutton_api_python import util as bbbUtil
from selenium import webdriver
Expand All @@ -27,6 +27,10 @@
parser.add_argument("-u","--user", help="Name to join the meeting",default="Live")
parser.add_argument("-r","--redis", help="Redis hostname",default="redis")
parser.add_argument("-c","--channel", help="Redis channel",default="chat")
parser.add_argument(
'--browser-disable-dev-shm-usage', action='store_true', default=False,
help='do not use /dev/shm',
)
args = parser.parse_args()

bbb = BigBlueButton(args.server,args.secret)
Expand All @@ -43,9 +47,20 @@ def set_up():
options.add_argument('--window-position=0,0')
options.add_experimental_option("excludeSwitches", ['enable-automation'])
options.add_argument('--incognito')
options.add_argument('--shm-size=1gb')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--start-fullscreen')
if args.browser_disable_dev_shm_usage:
options.add_argument('--disable-dev-shm-usage')
else:
dev_shm_size = int(subprocess.run('df /dev/shm/ --block-size=1M --output=size | tail -n 1', shell=True, stdout=subprocess.PIPE).stdout or '0')
required_dev_shm_size = 500 # in MB, 1024MB is recommended
if dev_shm_size < required_dev_shm_size:
logging.error(
'The size of /dev/shm/ is %sMB (minimum recommended is %sMB), '
'consider increasing the size of /dev/shm/ (shm-size docker parameter) or disabling /dev/shm usage '
'(see --browser-disable-dev-shm-usage or BROWSER_DISABLE_DEV_SHM_USAGE env variable).',
dev_shm_size, required_dev_shm_size
)
sys.exit(2)

logging.info('Starting browser to chat!!')

Expand Down
1 change: 1 addition & 0 deletions examples/docker-compose.yml.chat_example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
- app-tier
bbb-streamer:
image: aauzid/bigbluebutton-livestreaming
shm_size: '2gb'
environment:
# BigBlueButton Server url:
- BBB_URL=https://your_BigBlueButton_server/bigbluebutton/api
Expand Down
1 change: 1 addition & 0 deletions examples/docker-compose.yml.development
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3.3'
services:
bbb-streamer:
container_name: liveStreaming
shm_size: '2gb'
env_file: .env
build:
context: ./
1 change: 1 addition & 0 deletions examples/docker-compose.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
bbb-streamer:
image: aauzid/bigbluebutton-livestreaming
container_name: liveStreaming
shm_size: '2gb'
environment:
# BigBlueButton Server url:
- BBB_URL=https://your_BigBlueButton_server/bigbluebutton/api
Expand Down
10 changes: 8 additions & 2 deletions startStream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ then
RESOLUTION="${BBB_RESOLUTION}"
fi

DEV_SHM_USAGE="";
if [ "${BROWSER_DISABLE_DEV_SHM_USAGE}" = "true" ]
then
DEV_SHM_USAGE='--browser-disable-dev-shm-usage'
fi

if [ "${BBB_ENABLE_CHAT}" = "true" ]
then
xvfb-run -n 133 --server-args="-screen 0 1280x720x24" python3 chat.py -s ${BBB_URL} -p ${BBB_SECRET} -i "${BBB_MEETING_ID}" -r ${BBB_REDIS_HOST} -u "${BBB_CHAT_NAME}" -c ${BBB_REDIS_CHANNEL} $START_MEETING $ATTENDEE_PASSWORD $MODERATOR_PASSWORD -T "$MEETING_TITLE" &
xvfb-run -n 133 --server-args="-screen 0 1280x720x24" python3 chat.py -s ${BBB_URL} -p ${BBB_SECRET} -i "${BBB_MEETING_ID}" -r ${BBB_REDIS_HOST} -u "${BBB_CHAT_NAME}" -c ${BBB_REDIS_CHANNEL} $START_MEETING $ATTENDEE_PASSWORD $MODERATOR_PASSWORD $DEV_SHM_USAGE -T "$MEETING_TITLE" &
sleep 10
fi

xvfb-run -n 122 --server-args="-screen 0 ${RESOLUTION}x24" python3 stream.py -s ${BBB_URL} -p ${BBB_SECRET} -i "${BBB_MEETING_ID}" -u "${BBB_USER_NAME}" -r "${RESOLUTION}" ${SHOW_CHAT} $START_MEETING $ATTENDEE_PASSWORD $MODERATOR_PASSWORD -T "$MEETING_TITLE" $STREAM_MEETING $INTRO $BEGIN_INTRO $END_INTRO $DOWNLOAD_MEETING;
xvfb-run -n 122 --server-args="-screen 0 ${RESOLUTION}x24" python3 stream.py -s ${BBB_URL} -p ${BBB_SECRET} -i "${BBB_MEETING_ID}" -u "${BBB_USER_NAME}" -r "${RESOLUTION}" ${SHOW_CHAT} $START_MEETING $ATTENDEE_PASSWORD $MODERATOR_PASSWORD $DEV_SHM_USAGE -T "$MEETING_TITLE" $STREAM_MEETING $INTRO $BEGIN_INTRO $END_INTRO $DOWNLOAD_MEETING;
21 changes: 18 additions & 3 deletions stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
help='ffmpeg thread_queue_size options to be applied to all inputs (can be set using env)',
default=os.environ.get('FFMPEG_INPUT_THREAD_QUEUE_SIZE', '1024')
)
parser.add_argument(
'--browser-disable-dev-shm-usage', action='store_true', default=False,
help='do not use /dev/shm',
)

args = parser.parse_args()
# some ugly hacks for additional options
Expand Down Expand Up @@ -93,10 +97,21 @@ def set_up():
options.add_argument('--window-position=0,0')
options.add_experimental_option("excludeSwitches", ['enable-automation'])
options.add_experimental_option('prefs', {'intl.accept_languages':'{locale}'.format(locale='en_US.UTF-8')})
options.add_argument('--shm-size=1gb')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--start-fullscreen')

if args.browser_disable_dev_shm_usage:
options.add_argument('--disable-dev-shm-usage')
else:
dev_shm_size = int(subprocess.run('df /dev/shm/ --block-size=1M --output=size | tail -n 1', shell=True, stdout=subprocess.PIPE).stdout or '0')
required_dev_shm_size = 500 # in MB, 1024MB is recommended
if dev_shm_size < required_dev_shm_size:
logging.error(
'The size of /dev/shm/ is %sMB (minimum recommended is %sMB), '
'consider increasing the size of /dev/shm/ (shm-size docker parameter) or disabling /dev/shm usage '
'(see --browser-disable-dev-shm-usage or BROWSER_DISABLE_DEV_SHM_USAGE env variable).',
dev_shm_size, required_dev_shm_size
)
sys.exit(2)

logging.info('Starting browser!!')

browser = webdriver.Chrome(executable_path='./chromedriver',options=options)
Expand Down

0 comments on commit b510a1a

Please sign in to comment.