update-prod-static: Stop hiding output in update-prod-static.log.

Now that we've cleaned up this tool's output, there's no reason to use
an awkward mechanism to hide its output; we can just print it out like
a normal program.

Fixes #14644; resolves #14701.
This commit is contained in:
Tim Abbott 2020-04-24 13:24:11 -07:00
parent c880886cc3
commit 7e0eeb20a3
3 changed files with 14 additions and 41 deletions

View File

@ -3,7 +3,7 @@ import hashlib
import json
import shutil
from typing import Optional, List, IO, Any
from typing import Optional, List
from scripts.lib.zulip_tools import subprocess_text_output, run
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@ -49,8 +49,6 @@ def generate_sha1sum_node_modules(
def setup_node_modules(
production: bool = DEFAULT_PRODUCTION,
stdout: Optional[IO[Any]] = None,
stderr: Optional[IO[Any]] = None,
prefer_offline: bool = False,
) -> None:
yarn_args = get_yarn_args(production=production)
@ -64,9 +62,7 @@ def setup_node_modules(
if not os.path.exists(success_stamp):
do_yarn_install(target_path,
yarn_args,
success_stamp,
stdout=stdout,
stderr=stderr)
success_stamp)
print("Using cached node modules from %s" % (cached_node_modules,))
if os.path.islink('node_modules'):
@ -78,9 +74,7 @@ def setup_node_modules(
def do_yarn_install(
target_path: str,
yarn_args: List[str],
success_stamp: str,
stdout: Optional[IO[Any]] = None,
stderr: Optional[IO[Any]] = None,
success_stamp: str
) -> None:
os.makedirs(target_path, exist_ok=True)
shutil.copy('package.json', target_path)
@ -93,9 +87,8 @@ def do_yarn_install(
if os.path.exists("node_modules") and not os.path.exists(cached_node_modules):
shutil.copytree("node_modules/", cached_node_modules, symlinks=True)
if os.environ.get('CUSTOM_CA_CERTIFICATES'):
run([YARN_BIN, "config", "set", "cafile", os.environ['CUSTOM_CA_CERTIFICATES']],
stdout=stdout, stderr=stderr)
run([YARN_BIN, "config", "set", "cafile", os.environ['CUSTOM_CA_CERTIFICATES']])
run([YARN_BIN, "install", "--non-interactive", "--frozen-lockfile"] + yarn_args,
cwd=target_path, stdout=stdout, stderr=stderr)
cwd=target_path)
with open(success_stamp, 'w'):
pass

View File

@ -92,21 +92,7 @@ rabbitmq_password = 'not_used_here'
initial_password_salt = 'not_used_here'
EOF
# We do a bit of gymnastics to have update-prod-static.log be easily
# visible to the user and end up in the same directory as the final
# release tarball.
USER_PROD_STATIC_LOGPATH="$TMPDIR/update-prod-static.log"
BUILD_PROD_STATIC_LOGPATH="$TMPDIR/$prefix/var/log/update-prod-static.log"
ln -nfs "$BUILD_PROD_STATIC_LOGPATH" "$USER_PROD_STATIC_LOGPATH"
./tools/update-prod-static $authors_not_required || (
set +x
echo; echo -ne '\033[33mRunning update-prod-static failed. '
echo -e "Check $TMPDIR/update-prod-static.log for more information.\\033[0m"
exit 1
)
rm -f "$USER_PROD_STATIC_LOGPATH"
mv "$BUILD_PROD_STATIC_LOGPATH" "$USER_PROD_STATIC_LOGPATH"
./tools/update-prod-static $authors_not_required
# We don't need duplicate copies of emoji with hashed paths, and they would break bugdown
find prod-static/serve/generated/emoji/images/emoji/ -regex '.*\.[0-9a-f]+\.png' -delete

View File

@ -32,27 +32,23 @@ prev_deploy = args.prev_deploy
os.chdir(settings.DEPLOY_ROOT)
# Redirect child processes' output to a log file (most recent run only).
os.makedirs("var/log", exist_ok=True)
fp = open('var/log/update-prod-static.log', 'w')
# Install node packages
setup_node_modules(production=True, stdout=fp, stderr=fp)
setup_node_modules(production=True)
# Build emoji
run(['./tools/setup/emoji/build_emoji'], stdout=fp, stderr=fp)
run(['./tools/setup/emoji/build_emoji'])
# Inline CSS in emails
run(['./scripts/setup/inline_email_css.py'], stdout=fp, stderr=fp)
run(['./scripts/setup/inline_email_css.py'])
# Copy over static files from the zulip_bots package
run(['./tools/setup/generate_zulip_bots_static_files.py'], stdout=fp, stderr=fp)
run(['./tools/setup/generate_zulip_bots_static_files.py'])
# Build pygment data
run(['./tools/setup/build_pygments_data'], stdout=fp, stderr=fp)
run(['./tools/setup/build_pygments_data'])
# Create webpack bundle
run(['./tools/webpack', '--quiet'], stdout=fp, stderr=fp)
run(['./tools/webpack', '--quiet'])
# Collect the files that we're going to serve; this creates prod-static/serve.
run([
@ -65,12 +61,10 @@ run([
'-i', 'js',
'-i', 'styles',
'-i', 'templates',
], stdout=fp, stderr=fp)
])
# Compile translation strings to generate `.mo` files.
run(['./manage.py', 'compilemessages', '-v0'], stdout=fp, stderr=fp)
run(['./manage.py', 'compilemessages', '-v0'])
# Needed if PRODUCTION
os.makedirs('prod-static', exist_ok=True)
fp.close()