@@ -113,6 +113,15 @@
else
# start one build backend per CPU
NUM=`grep ^processor /proc/cpuinfo | wc -l`
+ # get total system memory and check if there is enough space for running
+ # CPUCOUNT * XENMEM + RAMDDISK Workers
+ MEM=$(cat /proc/meminfo | grep ^MemTotal: | awk -v NUM=${NUM} -v XENMEM=${XEN_MEMX} '{print $2 - (XENMEM * 1024*NUM+1572864) }')
+ if [ -n "${MEM}" ] ; then
+ until [ ${MEM} -gt 0 ] ; do
+ NUM=`expr ${NUM} - 1`
+ MEM=$(cat /proc/meminfo | grep ^MemTotal: | awk -v NUM=${NUM} -v XENMEM=${XEN_MEMX} '{print $2 - (XENMEM * 1024*NUM+1572864) }')
+ done
+ fi
#if [ "${NUM}" -gt 1 ] ; then
# NUM=`echo ${NUM} | awk '{print $1 * 1.5 }'`
#fi
@@ -138,12 +147,29 @@
chmod 755 bs_worker
popd
- # cleanup stale LVs / loops
+ # cleanup stale LVs / loops and setup cache/base volumes
if [ "$OBS_WORKER_USE_LVM" == "yes" ] ; then
lvremove -f abuild
+ OBS_CACHE_LV_SIZE=$((${OBS_CACHE_SIZE} + 500))
+ lvm lvcreate -n cache -L ${OBS_CACHE_LV_SIZE}M abuild
+ OBS_BASE_LV_SIZE=$((((${OBS_CACHE_SIZE} + 500)) * 2))
+ lvm lvcreate -n base -L ${OBS_BASE_LV_SIZE}M abuild
+
+ mkfs.xfs /dev/abuild/cache
+ mkdir -p ${OBS_CACHE_DIR}
+ mount -t xfs /dev/abuild/cache ${OBS_CACHE_DIR}
+
+ mkfs.xfs /dev/abuild/base
+ mkdir -p ${OBS_WORKER_DIRECTORY}
+ mount -t xfs /dev/abuild/base ${OBS_WORKER_DIRECTORY}
else
for a in `losetup -a|awk -F: '{print $1}'` ; do losetup -d $a ; done
fi
+ # create initrd for xen guests
+ if [ ! -f /boot/initrd ] ; then
+ mkinitrd -d /
+ ln -sf /boot/initrd-xen /boot/initrd
+ fi
while test "$NUM" -gt "$I"; do
if [ "$OBS_WORKER_PORTBASE" -gt 0 ]; then
port="--port $((OBS_WORKER_PORTBASE + I))"
@@ -180,29 +206,12 @@
o1=$o2
o2=$a
fi
- OBS_CACHE_LV_SIZE=$((${OBS_CACHE_SIZE} + 500))
- lvm lvcreate -n cache -L ${OBS_CACHE_LV_SIZE}M abuild
- OBS_BASE_LV_SIZE=$((((${OBS_CACHE_SIZE} + 500)) * 2))
- lvm lvcreate -n base -L ${OBS_BASE_LV_SIZE}M abuild
-
- mkfs.xfs /dev/abuild/cache
- mkdir -p ${OBS_CACHE_DIR}
- mount -t xfs /dev/abuild/cache ${OBS_CACHE_DIR}
-
- mkfs.xfs /dev/abuild/base
- mkdir -p ${OBS_WORKER_DIRECTORY}
- mount -t xfs /dev/abuild/base ${OBS_WORKER_DIRECTORY}
else
xen_opts="--device $ROOT/root_$I/root --swap $ROOT/root_$I/swap --vm-memory $XEN_MEMX"
dd if=/dev/zero of=$ROOT/root_$I/root bs=1M seek=$XEN_ROOT count=1
dd if=/dev/zero of=$ROOT/root_$I/swap bs=1M seek=$XEN_SWAP count=1
echo $XEN_MEMX > $ROOT/root_$I/memory
fi
- # create initrd for xen guests
- if [ ! -f /boot/initrd ] ; then
- mkinitrd -d /
- ln -sf /boot/initrd-xen /boot/initrd
- fi
fi
# prepare obsworker startup in screen...
echo "screen -t $title ./bs_worker $obsopt $xen_opts $port --root $ROOT/root_$I" \
|