upgrade-zulip: Shutdown servers with <3GB RAM when buiding static.

Fixes #14643.

This is to avoid running out of memory when building static assets
with webpack while server is running in low ram systems.
This commit is contained in:
Aman Agrawal 2020-04-19 12:28:41 +05:30 committed by Tim Abbott
parent 81195abdbd
commit da84b19aea
1 changed files with 12 additions and 0 deletions

View File

@ -158,6 +158,18 @@ if args.ignore_static_assets:
# cannot run `tools/update-prod-static`.
pass
elif args.from_git:
# Because `upgrade-zulip-from-git` needs to build static assets, it
# is at risk of being OOM killed on systems with limited free RAM.
mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
mem_gib = mem_bytes/(1024.**3) # e.g. 3.74
# Ideally, we'd have 2 thresholds here, depending on whether the
# system is running queue workers multithreaded or multiprocess.
# See puppet/zulip/manifests/app_frontend_base.pp for background.
if mem_gib < 3.8:
logging.info("Shutting down server to build static assets on a low-RAM system.")
shutdown_server()
# Note: The fact that this is before we apply puppet changes means
# that we don't support adding new puppet dependencies of
# update-prod-static with the git upgrade process. But it'll fail