Skip to content

Commit

Permalink
Improve nightly build handling
Browse files Browse the repository at this point in the history
  • Loading branch information
citrus-it committed Oct 17, 2017
1 parent da48eca commit d5676f3
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions bin/omni
Original file line number Diff line number Diff line change
Expand Up @@ -319,30 +319,51 @@ update_kayak()
)
}

terminate_illumos()
{
banner "Stopping illumos build, please wait..."
kill $nightlypid 2>/dev/null
pkill -P $tailpid
sleep 1
kill -9 $tailpid 2>/dev/null
}

build_illumos()
{
typeset env="${1:-${illumos_env}}"

lockf="$illumos_clone/log/nightly.lock"
if [ -h "$lockf" ]; then
ls -l "$lockf" | nawk '{print $NF}' | IFS=. read host user pid
kill -0 $pid 2>/dev/null \
&& abort "Illumos build already in progress."
banner "Stale build lockfile detected, ignoring."
fi

typeset benv=`basename $env`
banner "Starting illumos-omnios $release build... ($benv)"
ctrun -l child -o noorphan /opt/onbld/bin/nightly $env &
nightlypid=$!

# Remove any stale log file
[ -f $illumos_clone/log/nightly.log ] && \
rm -f $illumos_clone/log/nightly.log
while [ ! -f $illumos_clone/log/nightly.log ]; do
sleep 1
done

ctrun -l child -o noorphan /opt/onbld/bin/nightly $env &
nightlypid=$!

(
while [ ! -f $illumos_clone/log/nightly.log ]; do
sleep 1
done
tail -f $illumos_clone/log/nightly.log \
| egrep '^(====|real |user |sys )'
) &
tailpid=$!
trap "kill -9 $nightlypid $tailpid" INT

trap terminate_illumos INT
wait $nightlypid
trap - INT
pkill -9 -P $tailpid
sleep 5
kill -9 $tailpid
sleep 5
terminate_illumos
sleep 10
}

build_omnios()
Expand Down

0 comments on commit d5676f3

Please sign in to comment.