Jump to: navigation, search

Hudson-ci/Installing Hudson Unix Daemon

< Hudson-ci
Revision as of 14:45, 31 August 2011 by Duncan.r.mills.gmail.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

{hudson|pageTitle=Installing Hudson as a Unix Daemon}}

Some Available Options

Linux startup script

  • Sample Startup Script - a simple shell script enabling to start, stop, and restart hudson from /etc/init.d

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 as needed

Java Service Wrapper

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
  1. 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.
  2. 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
  1. Verify installation by starting the daemon through /etc/init.d/hudson start. Make sure that /etc/init.d/hudson has the correct permissions; normaly 755 is ok for this.

Examples

Ubuntu Linux

SuSE Linux