diff --git a/config.sh b/config.sh index 91bb461..957721d 100755 --- a/config.sh +++ b/config.sh @@ -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 diff --git a/update-website.sh b/update-website.sh index bc81fe7..e4b3bb5 100755 --- a/update-website.sh +++ b/update-website.sh @@ -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 @@ -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