News and Notes from the Makers of Nexus | Sonatype Blog

Hudson, Meet JavaServiceWrapper

Written by Tim OBrien | October 01, 2008

Here at Sonatype, we're working on a continuous integration build farm for testing the various open source projects we're involved with, including Nexus, m2eclipse, and of course Apache Maven. Yesterday, as part of this effort, I took a minute to repurpose some of the work we've done with JavaServiceWrapper for Nexus. By combining some of the techniques found in the Nexus build with the Hudson WAR file, I was able to create a bundle that wraps Hudson in JSW startup scripts and configuration. Obviously, this isn't a momentous achievement, but it is very convenient for anyone who wants to run a very simple Hudson instance, and have that instance recover automatically after a machine restart.

You can download the bundle at http://repository.sonatype.org/content/groups/public/org/sonatype/hudson/hudson-jsw/1.254-2/, or reference it via Maven using the following information:

Finally, to bring this full circle for RedHat/Fedora/CentOS users (in short, anyone with the chkconfig utility), you can integrate the above Hudson-JSW bundle into your sys-V init system using the following script in your /etc/init.d directory:

#!/bin/bash
#
# /etc/rc.d/init.d/atd
#
# Starts the hudson daemon
#
# chkconfig: 345 97 3
# description: Runs the Hudson CI server
# processname: hudson

export JAVA_HOME=/opt/java/sdk/1.6
export PATH=$JAVA_HOME/bin:$PATH

sudo -u hudson /opt/hudson/bin/jsw/linux-x86-64/hudson $*

Obviously, your own details may vary for user and JAVA_HOME.