[Piuparts-devel] Bug#678725: piuparts_slave_* broken

Dave Steele dsteele at gmail.com
Sun Jun 24 03:39:07 UTC 2012


Package: piuparts
Version: 0.45
Tags: patch
thanks

piuparts_slave_run and piuparts_slave_join are still pointing into the
obsolete org directory. Patch fixes this, and adds an optional command
line argument for multiple slave support.

https://github.com/davesteele/piuparts/commits/multiple-slaves

--------------------------------------

>From c1c2be8a684cdf5edb292faa092d101bd89ffb9e Mon Sep 17 00:00:00 2001
From: David Steele <dsteele at gmail.com>
Date: Thu, 17 May 2012 21:49:13 -0400
Subject: [PATCH] Modify slave_run and slave_join for multiple slave support

---
 debian/changelog     |    5 +++++
 slave-bin/slave_join |   17 ++++++++++++++---
 slave-bin/slave_run  |   48 ++++++++++++++++++++++++++++++++++++++++--------
 3 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 6207541..5b9bf46 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,11 @@ piuparts (0.46) UNRELEASED; urgency=low
     - Separate build and install targets.
     - Adjust for new layout, cleanup, simplify.

+  [ David Steele ]
+  * piuparts_slave_*
+    - Update to 0.45 paths.
+    - Add multiple slave support to piuparts_slave_run and piuparts_slave_join.
+
  -- Holger Levsen <holger at debian.org>  Thu, 21 Jun 2012 22:25:57 +0200

 piuparts (0.45) unstable; urgency=low
diff --git a/slave-bin/slave_join b/slave-bin/slave_join
index 26f47f6..8453a00 100755
--- a/slave-bin/slave_join
+++ b/slave-bin/slave_join
@@ -21,10 +21,21 @@
 #
 set -e

-SCREENLOG=/org/piuparts.debian.org/slave/screenlog.0
+if [ -z "$1" ] ; then
+   SLAVENUM=0
+else
+   SLAVENUM=$1
+fi
+
+if ! `echo $SLAVENUM | grep -E -e "^[0-9]{1}$" >/dev/null` ; then
+   echo "slave must be identified as a number between 0 and 9"
+   exit
+fi
+
+SCREENLOG=/var/lib/piuparts/slave/screenlog.$SLAVENUM

-if [ -f $SCREENLOG ] ; then
-  screen -R -S piuparts-slave-screen
+if [ -f $SCREENLOG ] ; then
+  screen -r -S piuparts-slave-screen -p $SLAVENUM -x
 else
   echo "$SCREENLOG does not exist, slave not running!"
   echo
diff --git a/slave-bin/slave_run b/slave-bin/slave_run
index 92b6ba5..587275b 100755
--- a/slave-bin/slave_run
+++ b/slave-bin/slave_run
@@ -21,17 +21,49 @@
 #
 set -e

-SCREENLOG=/org/piuparts.debian.org/slave/screenlog.0
-MONITORDIR=/org/piuparts.debian.org/master/monitor-slave
-export PYTHONPATH=/org/piuparts.debian.org/lib/python2.6/dist-packages:/org/piuparts.debian.org/lib/python2.7/dist-packages
+if [ -z "$1" ] ; then
+   SLAVENUM=0
+else
+   SLAVENUM=$1
+fi

-cd /org/piuparts.debian.org/slave
-(ps fax|grep -v grep| grep piuparts-slave ) && exit 0
-rm -f $SCREENLOG					# used by ~piupartsm/bin/detect_slave_problems
-rm -f $MONITORDIR/*					# used by several scripts to only warn once a day
+if ! `echo $SLAVENUM | grep -E -e "^[0-9]{1}$" >/dev/null` ; then
+   echo "slave must be identified as a number between 0 and 9"
+   exit
+fi
+
+
+SLAVEROOTDIR=/var/lib/piuparts/slave
+SLAVEDIR=$SLAVEROOTDIR/$SLAVENUM
+
+if [ ! -d $SLAVEDIR ] ; then
+   install -d $SLAVEDIR
+   chown piupartss:piuparts $SLAVEDIR
+fi
+
+SCREENLOG=$SLAVEROOTDIR/screenlog.$SLAVENUM
+MONITORDIR=/var/lib/piuparts/master/monitor-slave
+
+cd $SLAVEROOTDIR
+(ps fax|grep -v grep| grep piuparts-slave | grep $SLAVEDIR ) && exit 0
+rm -f $SCREENLOG || :					# used by ~piupartsm/bin/detect_slave_problems
+rm -f $MONITORDIR/*					# used by several scripts to only warn once a day

 trap "cat $SCREENLOG | mail -s 'slave abnormaly ended' piupartsm ; rm
$SCREENLOG; exit" TERM EXIT
-screen -L -d -m -S piuparts-slave-screen su - piupartss -c "cd
/org/piuparts.debian.org/slave && PYTHONPATH=$PYTHONPATH python
../share/piuparts/piuparts-slave"
+
+# if screen session does not exist, create it
+# remove screen logs to preserve slave_join logic
+( ps ax | grep SCREEN | grep piuparts-slave-screen >/dev/null) ||\
+    ( cd $SLAVEROOTDIR; screen -d -m -L -S piuparts-slave-screen;
sleep 1; rm -f $SLAVEROOTDIR/screenlog.*)
+
+# make sure there is a window for this slave
+screen -S piuparts-slave-screen -X screen -L $SLAVENUM
+
+# launch the slave
+screen -S piuparts-slave-screen -p $SLAVENUM -X stuff "
+su - piupartss -c \"cd $SLAVEDIR; python /usr/share/piuparts/piuparts-slave\"
+"
+
 trap - TERM EXIT

 echo "piuparts-slave has been started."
-- 
1.7.10





More information about the Piuparts-devel mailing list