Launching Cruise Control during Startup on OSX
June 22nd, 2008
I spent a good amount of time today trying to figure out how to turn my “old” iMac into a development environment, which included installing Cruise Control. Since I didn’t want to run the launch script manually, I tried (and failed) to find someone who’s successfully gotten cruise to autostart on boot. A bit of investigation later and I came up with a solution, drawn from an excellent blog post on adding your own osx boot launch scripts, an archive script on launching cruise on unix init, and the tacit information in the MySQLCOM Bootstrapper contained in the OSX Binary Distribution.
Step 1: Download and Install Cruise Control
You can download Cruise Control from Sourceforge. For the purpose of this demo I’ve used the binary distribution, though you can compile your own. Once you’ve downloaded your distribution, unzip it into a convenient directory. I’ve used the base applications directory: /Applications/CruiseControl.
Step 2: Create a User
It’s best practice to not run cruise as root, so open up your user accounts and create a new user called Cruise Control.
Step 3: Create a folder in the StartupItems directory.
$ sudo mkdir /Library/StartupItems/CruiseControl
Step 4: Create the Parameters File
Create a file called /Library/StartupItems/CruiseControl/StartupParameters.plist. This file will contain your startup launch configuration information- in other words it’s a file describing your startup task.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Description</key> <string>Cruise Control</string> <key>OrderPreference</key> <string>None</string> <key>Provides</key> <array> <string>CruiseControl</string> </array> <key>Uses</key> <array> <string>Network</string> </array> </dict> </plist>
Step 5: Create/Configure the launch script
The launch script needs to be command line executable with the following three options: start, stop, reset. I’ve included my sample here, but I recommend you adjust it to match your own configuration and user name.
#!/bin/sh
#
# Error out when no parameter given
if [ -z $1 ] ; then
echo "Usage: $0 [start|stop|restart] "
exit 1
fi
# Source the common setup functions for startup scripts
test -r /etc/rc.common || exit 1
. /etc/rc.common
###################################################################################################
# USER CONFIGURATION
# The user under which CruiseControl should run.
CC_USER=cruisecontrol
# Cruise Install Directory
CC_INSTALL_DIR=/Applications/CruiseControl
# Directory for the config.xml file.
CC_WORK_DIR=$CC_INSTALL_DIR
# Logfile Directory
CC_LOGFILE_DIR=$CC_INSTALL_DIR
# Port under which Cruise should run
CC_WEBPORT=8080
# JMX Port. It's suggested you don't change this unless the port is already in use.
CC_JMXPORT=8082
# Port for the RMI gateway, leave blank to disable.
CC_RMIPORT=
###################################################################################################
# DO NOT MODIFY ENTRIES BELOW THIS LINE
NAME=cruisecontrol
DESC="CruiseControl - continuous integration build loop"
PATH=/sbin:/usr/sbin:/usr/bin:/bin
export PATH
CC_DAEMON=$CC_INSTALL_DIR/cruisecontrol.sh
CC_CONFIG_FILE=$CC_WORK_DIR/config.xml
CC_LOG_FILE=$CC_LOGFILE_DIR/cruisecontrol.log
CC_COMMAND="$CC_DAEMON -configfile $CC_CONFIG_FILE -webport $CC_WEBPORT -jmxport $CC_JMXPORT -rmiport $CC_RMIPORT -user youruser -password supersecret"
# overwrite settings from default file
if [ -f /etc/default/cruisecontrol ]; then
. /etc/default/cruisecontrol
fi
# does the executable exist?
test -f $CC_DAEMON || (echo "The executable $CC_DAEMON does not exist!" && exit 0)
if [ `id -u` -ne 0 ]; then
echo "Not starting/stopping $DESC, you are not root."
exit 4
fi
# Get the PID output from the startup script
if [ -f $CC_INSTALL_DIR/cc.pid ]; then
CC_PID=`cat $CC_INSTALL_DIR/cc.pid`
else
echo "No cc.pid file found. CC process may not be controllable from this script!"
fi
StartService ()
{
cd $CC_INSTALL_DIR
su $CC_USER -c "/bin/sh -c \"$CC_COMMAND >> $CC_LOG_FILE 2>&1\"" & RETVAL=$?
echo "$NAME started with jmx on port ${CC_JMXPORT}"
}
StopService ()
{
if [ -n "$CC_PID" ] && ps -p ${CC_PID} > /dev/null ; then
kill -9 ${CC_PID}
RETVAL=$?
else
echo "$NAME is not running"
RETVAL=1
fi
}
RestartService ()
{
RunService "stop"
RunService "start"
}
RunService "$1"
Step 6: Set permissions
Given that the startup script will ignore anything that isn’t owned by root, and right now cruise still doesn’t have write access to the cruise install dir, we have to make a few adjustments to our file structure to make this work.
$ sudo chown -R cruisecontrol /Applications/CruiseControl $ sudo chown -R root /Library/StartupItems/CruiseControl $ sudo chmod 755 /Library/StartupItems/CruiseControl/CruiseControl
That’s it. I hope this was helpful

Good guide, thanks.
one note, though – you got /Libraries/ a few places – should be /Library/ everywhere.
/Jonas
Hah, nice catch. Thanks!
[...] on “how to start CruiseControl at launch of Mac OS X”.I’ve found a nice blogpost by Michael Krotscheck, which enables the wanted functionality, BUT: Sometimes I just don’t [...]