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'
 | 
			
		||||
API_KEY='mykey'
 | 
			
		||||
SERVER_PIPE='/var/tmp/micobu_pipe'
 | 
			
		||||
SERVER_LOCK='/var/tmp/micobu.lock'
 | 
			
		||||
 | 
			
		||||
BUILD_BASE=$ROOTFS_BASE$ROOTFS_DIR
 | 
			
		||||
 | 
			
		||||
@ -102,12 +103,27 @@ function build_s()
 | 
			
		||||
	shift
 | 
			
		||||
	echo Starting build of $@
 | 
			
		||||
	build $@
 | 
			
		||||
	rm "$SERVER_LOCK"
 | 
			
		||||
	echo "" > $SERVER_PIPE
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
rm -f "$SERVER_LOCK"
 | 
			
		||||
 | 
			
		||||
[ ! -p "$SERVER_PIPE" ] && mkfifo "$SERVER_PIPE"
 | 
			
		||||
a=()
 | 
			
		||||
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'`
 | 
			
		||||
	build_s $args
 | 
			
		||||
	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'`
 | 
			
		||||
	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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user