sh: Add build queue
This commit is contained in:
parent
55c103ce7d
commit
31b48cb92f
20
micobu.sh
20
micobu.sh
@ -10,6 +10,7 @@ ARTEFACT_BASE='/opt/micobu/rootfs/home/builduser/artefacts'
|
|||||||
BUILD_TIMEOUT='600'
|
BUILD_TIMEOUT='600'
|
||||||
API_KEY='mykey'
|
API_KEY='mykey'
|
||||||
SERVER_PIPE='/var/tmp/micobu_pipe'
|
SERVER_PIPE='/var/tmp/micobu_pipe'
|
||||||
|
SERVER_LOCK='/var/tmp/micobu.lock'
|
||||||
|
|
||||||
BUILD_BASE=$ROOTFS_BASE$ROOTFS_DIR
|
BUILD_BASE=$ROOTFS_BASE$ROOTFS_DIR
|
||||||
|
|
||||||
@ -102,12 +103,27 @@ function build_s()
|
|||||||
shift
|
shift
|
||||||
echo Starting build of $@
|
echo Starting build of $@
|
||||||
build $@
|
build $@
|
||||||
|
rm "$SERVER_LOCK"
|
||||||
|
echo "" > $SERVER_PIPE
|
||||||
}
|
}
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
rm -f "$SERVER_LOCK"
|
||||||
|
|
||||||
[ ! -p "$SERVER_PIPE" ] && mkfifo "$SERVER_PIPE"
|
[ ! -p "$SERVER_PIPE" ] && mkfifo "$SERVER_PIPE"
|
||||||
|
a=()
|
||||||
while true; do
|
while true; do
|
||||||
args=`cat $SERVER_PIPE | sed -n 's/\([a-zA-Z0-9]\+\) \([a-zA-Z0-9]\+\) \([a-zA-Z0-9:\-_\/\.]\+\) \([a-z0-9]\+\)/\1 \2 \3 \4/p'`
|
line=`head -n 1 $SERVER_PIPE | sed -n 's/\([a-zA-Z0-9]\+\) \([a-zA-Z0-9]\+\) \([a-zA-Z0-9:\-_\/\.]\+\) \([a-z0-9]\+\)/\1 \2 \3 \4/p'`
|
||||||
build_s $args
|
if [ "$line" != "" ]; then
|
||||||
|
a=("${a[@]}" "$line")
|
||||||
|
fi
|
||||||
|
if [ "$a" != "" ]; then
|
||||||
|
if [ ! -f "$SERVER_LOCK" ]; then
|
||||||
|
echo "Starting build: $a"
|
||||||
|
touch "$SERVER_LOCK"
|
||||||
|
build_s $a &
|
||||||
|
a=("${a[@]:1}")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user