Skip to content
This repository has been archived by the owner on Jun 1, 2020. It is now read-only.

Commit

Permalink
add timeout support, default=600 secs, close #16
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Dec 26, 2015
1 parent 6773a4b commit c2bf485
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ forceUpdateRepo=false

pushMetaOnGitHub=false

timeout=600 #maximun execution time for a command, in second

logFile='build.log'
logMode='clean' #append|clean
logPath='' #if empty, log will be placed at the root of buildScript
12 changes: 11 additions & 1 deletion update-website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ pth="$(dirname $(readlink -f $0))"
updateMeta=$forceUpdateMeta
updateRepo=$forceUpdateRepo

if [[ ! $timeout =~ ^[0-9]+$ ]] || [ $timeout -le 3 ]; then
timeout=3
fi

eval logPath=$logPath
if [ -z "$logPath" ] || [ ! -d "$logPath" ] || [ ! -w "$logPath" ] ; then
logPath=$pth
Expand Down Expand Up @@ -53,7 +57,13 @@ function error()
function run()
{
echo "`date` [command] $@" >> $logPath/$logFile
"$@" || error "Got error while running command: '$@'"
timelimit -q -s 9 -t $((timeout - 2)) -T $timeout "$@"
exitStatus=$?
if [ $exitStatus -eq 137 ]; then
error "Got timeout($timeout sec) while running command: '$@'"
elif [ $exitStatus -ne 0 ]; then
error "Got error while running command: '$@'"
fi
}

if [ ! -d "$basePath/$mainRepo" ]; then
Expand Down

0 comments on commit c2bf485

Please sign in to comment.