From 6364f9941986752efd1e9bfbfff63d4e276d21f0 Mon Sep 17 00:00:00 2001 From: Saivann Date: Sat, 11 Apr 2015 10:02:24 -0400 Subject: [PATCH] Fix endless loop bug in build scripts --- _build/update_site.sh | 10 ++++++++-- _build/update_txpreview.sh | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/_build/update_site.sh b/_build/update_site.sh index 742cc31e..b2040f7e 100755 --- a/_build/update_site.sh +++ b/_build/update_site.sh @@ -49,14 +49,19 @@ lasttime=`stat -c %Y "$SITEDIR/_buildlock" | cut -d ' ' -f1` # Build website in a child process ( cd $WORKDIR -JEKYLL_COMMAND='jekyll' make build -touch "$WORKDIR/_builddone" +make valid && touch "$WORKDIR/_builddone" || touch "$WORKDIR/_buildfail" )& # Loop every 1 second to check status while true do + # Exit if site has been failed to build + if [ -e "$WORKDIR/_buildfail" ]; then + echo "Build failed" + exit + fi + # Update site and exit if site has been successfully built if [ -e "$WORKDIR/_builddone" ]; then rsync --delete -zrt $WORKDIR/_site/ $DESTDIR/ @@ -69,6 +74,7 @@ do time=`stat -c %Y "$SITEDIR/_buildlock" | cut -d ' ' -f1` fi if [ $time != $lasttime ]; then + echo "Build cancelled" exit fi sleep 1 diff --git a/_build/update_txpreview.sh b/_build/update_txpreview.sh index 115e65ae..e782d1bb 100755 --- a/_build/update_txpreview.sh +++ b/_build/update_txpreview.sh @@ -91,14 +91,19 @@ done # Build website in a child process ( cd $WORKDIR -ENABLED_PLUGINS='alerts redirects releases' JEKYLL_COMMAND='jekyll' make -touch "$WORKDIR/_builddone" +ENABLED_PLUGINS='alerts redirects releases' make build && touch "$WORKDIR/_builddone" || touch "$WORKDIR/_buildfail" )& # Loop every 1 second to check status while true do + # Exit if site has been failed to build + if [ -e "$WORKDIR/_buildfail" ]; then + echo "Build failed" + exit + fi + # Update site and exit if site has been successfully built if [ -e "$WORKDIR/_builddone" ]; then cd $LIVEDIR @@ -112,6 +117,7 @@ do time=`stat -c %Y "$SITEDIR/site/_buildlock" | cut -d ' ' -f1` fi if [ $time != $lasttime ]; then + echo "Build cancelled" exit fi sleep 1