Skip to content

Commit

Permalink
Exit on small /dev/shm/
Browse files Browse the repository at this point in the history
  • Loading branch information
tochev committed Dec 11, 2020
1 parent 84f4d89 commit 060c9d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ def set_up():
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')
if dev_shm_size < 256: # 1024MB is recommended
logging.warning('The size of /dev/shm/ is %sMB, consider disabling dev-shm-usage or increase the size of /dev/shm', dev_shm_size)
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
11 changes: 9 additions & 2 deletions stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@ def set_up():
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')
if dev_shm_size < 256: # 1024MB is recommended
logging.warning('The size of /dev/shm/ is %sMB, consider disabling dev-shm-usage or increase the size of /dev/shm', dev_shm_size)
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!!')

Expand Down

0 comments on commit 060c9d1

Please sign in to comment.