Add status script.

This commit is contained in:
Eli Barzilay 2012-01-07 09:34:26 -05:00
parent efc5a05049
commit 465a8da995
2 changed files with 77 additions and 0 deletions

View File

@ -158,6 +158,8 @@ drtestscript="$scriptdir/test-drracket.rkt"
bundlescript="$scriptdir/bundle" bundlescript="$scriptdir/bundle"
# web build script # web build script
webscript="collects/meta/web/build.rkt" webscript="collects/meta/web/build.rkt"
# status script
statusscript="$scriptdir/current-build-status.cgi"
# url mirrors file (relative to $maindir) # url mirrors file (relative to $maindir)
knownmirrors="known-mirror-urls" knownmirrors="known-mirror-urls"
# sitemap materials # sitemap materials
@ -2176,6 +2178,22 @@ BUILD_PRE_WEB() {
> /dev/null > /dev/null
fi fi
## --------------------------------------------------------------------------
# Make the status script available for use
if [[ "$prewebdir" = "$prewebdir_default" ]]; then
{
echo "#!/bin/bash"
local v
for v in tmpdir lockfile statusfile statusfile_last bglogfile; do
echo "$v=$(eval "\$$var")"
done
echo ""
cat "$PLTHOME/$statusscript"
} > "${prewebdir}/$(basename "$statusscript")"
chmod +x "${prewebdir}/$(basename "$statusscript")"
fi
} }

View File

@ -0,0 +1,59 @@
# these should be writable
cache="/tmp/racket-build-status-cache"
cachelock="$cache-lock"
printf 'Content-type: text/plain\r\n\r\n'
# cache status reports (avoids excessive work during builds)
# use a lockfile as a cheap hack to time cache refreshing
if ! lockfile -r 0 -l 5 -s 0 "$cachelock" && [[ -e "$cache" ]]; then
cat "$cache"; exit
fi
{
files=""
if [[ -e "$lockfile" ]]; then L="Y"; else L="N"; fi
if [[ -e "$statusfile" ]]; then S="Y"; else S="N"; fi
if [[ -e "$statusfile_last" ]]; then S1="Y"; else S1="N"; fi
if [[ "$L$S" = "NY" ]]; then
printf 'Last build crashed abnormally.\n'
elif [[ "$S" = "Y" ]]; then
printf 'Running: '; cat "$statusfile"
time_for_file() {
local t="$(($(date +"%s") - $(stat -c "%Z" "$1")))"
printf "%d:%02d:%02d" "$((t/3600))" "$(((t%3600)/60))" "$((t%60))"
}
printf "The build has been running for %s, current step for %s\n" \
"$(time_for_file "$lockfile")" "$(time_for_file "$statusfile")"
shopt -s nullglob
if [[ "x$(echo "$bglogfile"*)" != "x" ]]; then
printf '\n%s build jobs running:\n' "$(ls "$bglogfile"* | wc -l)"
for bg in "$bglogfile"*; do
printf ' %s: ' "${bg#$bglogfile-}"
s="$(grep "^### <<< .* >>>" "$bg" | tail -1 \
| sed -e 's/^### <<< \(.*\) >>>/\1/')"
if [[ "x$s" = "x" ]]; then echo "(just starting)"; else echo "$s"; fi
done
fi
else
printf 'No build is running.\n'
if [[ "$S1" = "Y" ]]; then
last="$(cat "$statusfile_last")"
if [[ "x$last" = "xDone ("*")" ]]; then
last="${last#Done (}"
last="${last%)}"
printf 'Last build successfully ended at %s\n' "$last"
else
printf 'Last build was unsuccessful (while: %s)\n' "$last"
fi
fi
if [[ "$L" = "Y" ]]; then
printf '(Builds temporarily disabled)\n'
fi
fi
} > "$cache" 2>&1
cat "$cache"