Skip to content

Commit

Permalink
Fix endless loop bug in build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
saivann committed Apr 11, 2015
1 parent c71e9fd commit 6364f99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions _build/update_site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions _build/update_txpreview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6364f99

Please sign in to comment.