Fix endless loop bug in build scripts

This commit is contained in:
Saivann 2015-04-11 10:02:24 -04:00
parent c71e9fdf2d
commit 6364f99419
2 changed files with 16 additions and 4 deletions

View file

@ -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