[-]
[+]
|
Changed |
j0ke-worker.spec
|
|
[-]
[+]
|
Changed |
obsworker
^
|
@@ -10,31 +10,77 @@
### BEGIN INIT INFO
# Provides: obsworker
# Required-Start: $time $network $syslog
-# Required-Stop: $null
-# Should-Start: obsscheduler
-# Should-Stop: $null
+# Required-Stop: $time $network $syslog
+# Should-Start: $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Description: openSUSE build service worker
### END INIT INFO
-[ -f /etc/rc.status ] && . /etc/rc.status
+. /etc/rc.status
. /etc/sysconfig/obs-worker
# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}
-workerdir=/var/run/obsworker
-workerbootdir="$workerdir"/boot
-screenrc=/var/run/obsworker/boot/screenrc
-obsopt=""
+if [ -z "$OBS_RUN_DIR" ]; then
+ OBS_RUN_DIR="/var/run/obs"
+fi
+if [ -z "$OBS_LOG_DIR" ]; then
+ OBS_LOG_DIR="/var/log/obs"
+fi
+if [ -z "$OBS_REPO_SERVERS" ]; then
+ OBS_REPO_SERVERS="localhost:6262"
+fi
if [ -z "$OBS_SRC_SERVER" ]; then
OBS_SRC_SERVER="localhost:6362"
fi
-if [ -z "$OBS_REPO_SERVER" ]; then
- OBS_REPO_SERVER="localhost:6262"
+
+if [ -n "$OBS_USE_SLP" ]; then
+ OBS_SRC_PARM=`slptool findsrvs service:obs.source_server | sed -n 's/service:obs.source_server:\([^,]*\),.*/--srcserver \1/p' | head -n 1`
+ for i in `slptool findsrvs service:obs.repo_server | sed -n 's/service:obs.repo_server:\([^,]*\),.*/\1/p'`; do
+ OBS_REPO_PARM="$OBS_REPO_PARM --reposerver $i"
+ done
+fi
+if [ -n "$OBS_WORKER_TEST_MODE" ]; then
+ OBS_TEST="--test"
+fi
+if [ -n "$OBS_WORKER_JOBS" ]; then
+ OBS_JOBS="--jobs $OBS_WORKER_JOBS"
+fi
+
+if [ -z "$OBS_SRC_PARM" ]; then
+ OBS_SRC_PARM="--srcserver http://$OBS_SRC_SERVER"
+fi
+if [ -z "$OBS_REPO_PARM" ]; then
+ for i in $OBS_REPO_SERVERS; do
+ if [ -z "$OBS_WORKER_PARM" ]; then
+ OBS_WORKER_PARM="http://$i"
+ fi
+ OBS_REPO_PARM="$OBS_REPO_PARM --reposerver http://$i"
+ done
+fi
+
+obsrundir="$OBS_RUN_DIR"
+workerdir="$obsrundir"/worker
+workerbootdir="$workerdir"/boot
+screenrc="$workerdir"/boot/screenrc
+obsopt=""
+OBS_WORKER_OPT=""
+
+if [ -n "$OBS_CACHE_DIR" ]; then
+ OBS_WORKER_OPT="--cachedir $OBS_CACHE_DIR"
+fi
+
+if [ -n "$OBS_CACHE_SIZE" ]; then
+ if [ -z "$OBS_CACHE_DIR" ]; then
+ OBS_CACHE_DIR="/tmp/workercache"
+ OBS_WORKER_OPT="--cachedir $OBS_CACHE_DIR"
+ fi
+ mkdir $OBS_CACHE_DIR
+ OBS_WORKER_OPT="$OBS_WORKER_OPT --cachesize $OBS_CACHE_SIZE "
fi
if [ -f /etc/buildhost.config ];then
@@ -42,10 +88,17 @@
obsopt=--xen
fi
+if [ -f /etc/kvmbuildhost.config ]; then
+ . /etc/kvmbuildhost.config
+ obsopt=--kvm
+fi
+
rc_reset
case "$1" in
start)
# reset screenrc
+ mkdir -p "$obsrundir"
+ chown obsrun:obsrun "$obsrundir"
rm -rf "$workerdir"
mkdir -p "$workerbootdir"
echo "zombie on" > $screenrc
@@ -59,7 +112,6 @@
if [ "${NUM}" -gt 1 ] ; then
NUM=`echo ${NUM} | awk '{print $1 * 1.5 }'`
fi
-
fi
I=0
ROOT="/tmp"
@@ -70,13 +122,14 @@
# fetch worker sources from server
pushd "$workerbootdir"
- curl -q "http://$OBS_REPO_SERVER"/getworkercode | cpio --extract
+ curl -q "${OBS_WORKER_PARM}"/getworkercode | cpio --extract
ln -s . XML
chmod 755 bs_worker
popd
# cleanup stale loops
for a in `losetup -a|awk -F: '{print $1}'` ; do losetup -d $a ; done
+
while test "$NUM" -gt "$I"; do
if [ "$OBS_WORKER_PORTBASE" -gt 0 ]; then
port="--port $((OBS_WORKER_PORTBASE + I))"
@@ -87,8 +140,8 @@
title="$HOSTNAME/$I"
# prepare obsworker startup in screen...
echo "screen -t $title ./bs_worker $obsopt $port --root $ROOT/root_$I" \
- "--statedir $workerdir/$I --id $HOSTNAME/$I --reposerver http://$OBS_REPO_SERVER" \
- "--srcserver http://$OBS_SRC_SERVER" \
+ "--statedir $workerdir/$I --id $HOSTNAME/$I $OBS_REPO_PARM" \
+ "$OBS_JOBS $OBS_TEST $OBS_SRC_PARM $OBS_WORKER_OPT" \
>> $screenrc
mkdir $workerdir/$I
# prepare xen build setup...
@@ -100,11 +153,7 @@
# XEN_MEMX=[n]
# ---
if [ -d $ROOT/root_$I ];then
- # extra cleanup
- umount $ROOT/root_$I/root
-
rm -rf $ROOT/root_$I
- mkdir -p $ROOT/root_$I
else
mkdir -p $ROOT/root_$I
fi
@@ -120,8 +169,8 @@
;;
stop)
echo -n "Shutting down obsworker"
- killall bs_worker
- ps axu|grep obsworker|grep -i screen| awk '{print "kill -9 "$2}'|sh
+ ps axu|grep obsworker|grep -i screen| awk '{print "kill -9 "$2}'|sh
+ killall bs_worker
rc_status -v
;;
restart)
|
[-]
[+]
|
Changed |
sysconfig.obs-worker
^
|
@@ -16,7 +16,7 @@
#
#
-OBS_REPO_SERVER="backend.obs.j0ke.net:6262"
+OBS_REPO_SERVERS="backend.obs.j0ke.net:6362"
## Path: Applications/OBS
## Description: define number of build instances
@@ -47,3 +47,62 @@
# 0 means let the operating system assign a port number
OBS_WORKER_PORTBASE="23000"
+
+## Path: Applications/OBS
+## Description: Number of parallel compile jobs per worker
+## Type: integer
+## Default: "1"
+## Config: OBS
+#
+
+OBS_WORKER_JOBS="1"
+
+## Path: Applications/OBS
+## Description: Run in test mode (build results will be ignore, no job blocking)
+## Type: ("yes" | "")
+## Default: ""
+## Config: OBS
+#
+
+OBS_WORKER_TEST_MODE=""
+
+## Path: Applications/OBS
+## Description: The base for OBS communucation directory
+## Type: string
+## Default: "/var/run/obs"
+## Config: OBS
+OBS_RUN_DIR="/var/run/obs"
+
+## Path: Applications/OBS
+## Description: The base for OBS logging directory
+## Type: string
+## Default: "/var/log/obs"
+## Config: OBS
+OBS_LOG_DIR="/var/log/obs"
+
+## Path: Applications/OBS
+## Description: Register in SLP server
+## Type: ("yes" | "")
+## Default: ""
+## Config: OBS
+#
+#
+OBS_USE_SLP=""
+
+## Path: Applications/OBS
+## Description: Register in SLP server
+## Type: string
+## Default: ""
+## Config: OBS
+#
+#
+OBS_CACHE_DIR="/home/obs/cache"
+
+## Path: Applications/OBS
+## Description: Register in SLP server
+## Type: size in MB
+## Default: ""
+## Config: OBS
+#
+#
+OBS_CACHE_SIZE="5120"
|