Installing Hudson as a Unix daemon

Linux startup script

daemonize

daemonize is a very simple program that allows you to launch Hudson (or any arbitrary program) as a daemon. For people without much Unix experience, this is recommended.

daemontools

daemontools is another possibility. This is more complicated to set up and it doesn't really follow the normal Unix convention, but it offers daemon control (like start/stop), log capturing, as well as automatic restart when the service dies.

Shell script

        # Daemonize
        echo -n $"Starting $SERVICE: "
        touch /var/run/hudson.pid
        chown hudson:hudson /var/run/hudson.pid
        su -s /bin/sh hudson -c "
                cd /
                HUDSON_HOME=/var/lib/hudson exec setsid /usr/bin/java   \
                        -jar /usr/share/java/hudson/hudson.war          \
                        $HUDSON_OPTS                                    \
                </dev/null >>/var/log/hudson/console_log 2>&1 &
                echo \$! >/var/run/hudson.pid
                disown \$!
                "

Adjust the above for your need – it is the part of my init scripts.

Java Service Wrapper

The The Java Service wrapper is a wrapper that works both on Unix and Windows. It requires some set up but when it is setup it can be used as any other unix service (like start/stop).

This example will install a hudson instance in /home/hudson on a debian machine. The Hudson configuration is stored in /home/hudson/data. Hudson will be running on port 8070 and as the hudson user.

  1. Select and download a JSW package from the JSW wrapper download page.
  2. Unpack the package into the /home/hudson path.
  3. Create /home/hudson/tmp as the temporary directory for JSW.
  4. Download the Hudson.war file into /home/hudson/lib.
    • If you have plugins that you would like to use, download them into /home/hudson/data/plugins.
  5. Copy the /home/hudson/src/conf/wrapper.conf.in to /home/hudson/conf/wrapper.conf and change the below configuration properties in the file.
    wrapper.java.classpath.1=../lib/hudson.war
    wrapper.java.classpath.2=../lib/wrapper.jar
    
    wrapper.java.additional.1=-DHUDSON_HOME=../data
    wrapper.java.additional.2=-Djava.io.tmpdir=../tmp
    wrapper.java.additional.3=-server
    
    # Set directly the time zone of the JVM, by setting this we do not rely on the time zone of the server.
    # Uncomment the following line if needed.
    # wrapper.java.additional.4=-Duser.timezone=America/Los_Angeles
    
    wrapper.app.parameter.1=Main
    wrapper.app.parameter.2=--httpPort=8070
    
    wrapper.ping.timeout=300
    wrapper.jvm_exit.timeout=60
    
    wrapper.console.title=Hudson Continuous build server
    
  6. Verify the wrapper configuration by starting Hudson through /home/hudson/bin/testwrapper console. Hudson should be accessible through http://localhost:8070, if not check the console output for errors.
  7. Copy the /home/hudson/src/bin/sh.script.in to /etc/init.d/hudson and change the below configuration properties in the file.
    APP_NAME="Hudson"
    APP_LONG_NAME="Hudson Continuous build server"
    
    WRAPPER_CMD="/home/hudson/bin/wrapper"
    WRAPPER_CONF="/home/hudson/conf/wrapper.conf"
    
    PIDDIR="/home/hudson/bin"
    
    RUN_AS_USER=hudson
    
  8. Verify installation by starting the daemon through /etc/init.d/hudson start
    Please feel free to add your suggestion here

Examples

Ubuntu Linux

Init Script for Hudson Continuous Integration Engine on Ubuntu Linux

SuSE Linux

Init Script for Hudson Continuous Integration Engine on SuSE Linux

Labels:

init init Delete
script script Delete
daemon daemon Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.