<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -21,7 +21,13 @@ if [ -f /etc/sysconfig/puppetmaster ]; then
 fi
 
 PUPPETMASTER_OPTS=&quot;&quot;
+[ -n &quot;$PUPPETMASTER_PID_DIR&quot; ] || PUPPETMASTER_PID_DIR=&quot;/var/run/puppet/&quot;
 [ -n &quot;$PUPPETMASTER_MANIFEST&quot; ] &amp;&amp; PUPPETMASTER_OPTS=&quot;--manifest=${PUPPETMASTER_MANIFEST}&quot;
+if [ -n &quot;$PUPPETMASTER_PORTS&quot; ] &amp;&amp; [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then
+    PUPPETMASTER_OPTS=&quot;$PUPPETMASTER_OPTS --servertype=mongrel&quot;
+elif [ -n &quot;$PUPPETMASTER_PORTS&quot; ] &amp;&amp; [ ${#PUPPETMASTER_PORTS[@]} -eq 1 ]; then
+    PUPPETMASTER_OPTS=&quot;${PUPPETMASTER_OPTS} --masterport=${PUPPETMASTER_PORTS[0]}&quot; 
+fi
 [ -n &quot;$PUPPETMASTER_LOG&quot; ] &amp;&amp; PUPPETMASTER_OPTS=&quot;${PUPPETMASTER_OPTS} --logdest=${PUPPETMASTER_LOG}&quot;
 PUPPETMASTER_OPTS=&quot;${PUPPETMASTER_OPTS} \
 	${PUPPETMASTER_EXTRA_OPTS}&quot;
@@ -36,8 +42,18 @@ start() {
 
 	# Confirm the manifest exists
 	if [ -r $PUPPETMASTER_MANIFEST ]; then
-		daemon $PUPPETMASTER $PUPPETMASTER_OPTS
-		RETVAL=$?
+        if [ -n &quot;$PUPPETMASTER_PORTS&quot; ] &amp;&amp; [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then
+            echo -n &quot; (port &quot;
+            for ((i=0; i&lt;${#PUPPETMASTER_PORTS[@]}; i++)); do
+                echo -n &quot;${PUPPETMASTER_PORTS[$i]}&quot;
+                daemon $PUPPETMASTER $PUPPETMASTER_OPTS --masterport=${PUPPETMASTER_PORTS[$i]} --pidfile=$PUPPETMASTER_PID_DIR/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid
+                RETVAL=$? || $RETVAL
+            done
+            echo -n &quot;)&quot;
+        else
+            daemon $PUPPETMASTER $PUPPETMASTER_OPTS
+            RETVAL=$?
+        fi
 	else
 		failure $&quot;Manifest does not exist: $PUPPETMASTER_MANIFEST&quot;
 		echo
@@ -50,8 +66,18 @@ start() {
 
 stop() {
 	echo -n  $&quot;Stopping puppetmaster: &quot;
-	killproc $PUPPETMASTER
-	RETVAL=$?
+    if [ -n &quot;$PUPPETMASTER_PORTS&quot; ] &amp;&amp; [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then
+        echo -n &quot; (port &quot;
+        for ((i=0; i&lt;${#PUPPETMASTER_PORTS[@]}; i++)); do
+            echo -n &quot;${PUPPETMASTER_PORTS[$i]}&quot;
+            killproc -p $PUPPETMASTER_PID_DIR/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid $PUPPETMASTER
+            RETVAL=$? || $RETVAL
+        done
+        echo -n &quot;)&quot;
+    else
+       killproc $PUPPETMASTER
+       RETVAL=$?
+    fi
 	echo
 	[ $RETVAL -eq 0 ] &amp;&amp; rm -f &quot;$lockfile&quot;
 	return $RETVAL</diff>
      <filename>conf/redhat/server.init</filename>
    </modified>
    <modified>
      <diff>@@ -5,5 +5,26 @@
 # Specify syslog to send log messages to the system log.
 #PUPPETMASTER_LOG=syslog
 
+# You may specify an alternate port or an array of ports on which 
+# puppetmaster should listen. Default is: 8140
+# If you specify more than one port, the puppetmaster ist automatically
+# started with the servertype set to mongrel. This might be interesting
+# if you'd like to run your puppetmaster in a loadbalanced cluster.
+# Please note: this won't setup nor start any loadbalancer. 
+# If you'd like to run puppetmaster with mongrel as servertype but only
+# on one (specified) port, you have to add --servertype=mongrel to
+# PUPPETMASTER_EXTRA_OPTS.
+# Default: Empty (Puppetmaster isn't started with mongrel, nor on a 
+# specific port)
+#PUPPETMASTER_PORTS=&quot;&quot;
+# Puppetmaster on a different port, run with standard webrick servertype
+#PUPPETMASTER_PORTS=&quot;8141&quot;
+# Example with multiple ports which will start puppetmaster with mongrel
+# as a servertype
+#PUPPETMASTER_PORTS=( 18140 18141 18142 18143 )
+
+# You may specify an alternate pid directory.
+#PUPPETMASTER_PID_DIR=/var/run/puppet
+
 # You may specify other parameters to the puppetmaster here
 #PUPPETMASTER_EXTRA_OPTS=--noca</diff>
      <filename>conf/redhat/server.sysconfig</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>40375a8fc34dbd85d87f507ba72c7394b25b7271</id>
    </parent>
  </parents>
  <author>
    <name>Marcel Haerry</name>
    <email>haerry@puzzle.ch</email>
  </author>
  <url>http://github.com/duritong/puppet/commit/c202da54da409e08efb6225e2190d465bd481ca4</url>
  <id>c202da54da409e08efb6225e2190d465bd481ca4</id>
  <committed-date>2008-07-29T01:03:07-07:00</committed-date>
  <authored-date>2008-07-29T01:03:07-07:00</authored-date>
  <message>enhance redhat puppetmaster init.d script to easy start puppetmaster as a mongrel cluster

If you'd like to run puppetmaster in a mongrel cluster you have to start X instances of
puppetmaster with servertype set to mongrel. With this patch you can add more than one port
to the sysconfig file and puppetmaster will automatically be started with severtype set to
mongrel.
You can now even specify an alternate port in the sysconfig file on which puppetmaster
should be run as webrick based server. See sysconfig file for more documentation.</message>
  <tree>4d365fb8375a2345f31a3cabaefa3ec63111066c</tree>
  <committer>
    <name>Marcel Haerry</name>
    <email>haerry@puzzle.ch</email>
  </committer>
</commit>
