InstallationHudson has native integrations with the following OSes. See respective sections for how to make Hudson run in the background automatically:
Alternatively, if you have a servlet container that supports Servlet 2.4/JSP 2.0, such as Glassfish v2, Tomcat 5 (or any later versions), then you can run them as services, and deploy hudson.war as you would any other war file. Container specific documentation is available if you choose this route. Windows InstallationIf you're running on Windows you might want to run Hudson as a service so it starts up automatically without requiring a user to log in. The easiest way is follow Installing Hudson as a Windows service. Alternatively, you can install a servlet container like GlassFish and Tomcat, which can run as a service by itself, and then deploy Hudson to it. Case StudiesAlso, see how other people are deploying Hudson to get some idea of how to make it fit your environment.
ExecutionAs mentioned above, the easiest way to execute Hudson is through the built in Winstone servlet container. You can execute Hudson like this: $ java -jar hudson.war Of course, you probably want to send the output of Hudson to a log file, and if you're on Unix, you probably want to use nohup: $ nohup java -jar hudson.war > $LOGFILE 2>&1 To see Hudson, simply bring up a web browser and go to URL http://*myServer:8080{*} where myServer is the name of the system running Hudson. Command Line ParametersHudson normally starts up using port 8080, however, if you have other web services starting up, you might find that this port is already taken, you can specify a different port by using the --httpPort=$HTTP_PORT where $HTTP_PORT is the port you want Hudson to run on. Other command line parameters include:
Hudson passes all command line parameters to the Winstone servlet container, so you can get more information by looking at the Winstone Command Line Parameter Reference
A very simple init script#!/bin/sh DESC="Hudson CI Server" NAME=hudson PIDFILE=/var/run/$NAME.pid RUN_AS=hudson COMMAND=java -jar /home/hudson/hudson.war d_start() { start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --chuid $RUN_AS --exec $COMMAND } d_stop() { start-stop-daemon --stop --quiet --pidfile $PIDFILE if [ -e $PIDFILE ] then rm $PIDFILE fi } case $1 in start) echo -n "Starting $DESC: $NAME" d_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" d_stop echo "." ;; restart) echo -n "Restarting $DESC: $NAME" d_stop sleep 1 d_start echo "." ;; *) echo "usage: $NAME {start|stop|restart}" exit 1 ;; esac exit 0 In Ubuntu 9.04-Server this init-script doesn't work. You have to change the start line to start-stop-daemon --start --quiet --background -m --pidfile $PIDFILE --chuid $RUN_AS --exec /usr/bin/java -- -jar /opt/hudson/hudson.war |

Comments (7)
Dec 18, 2007
Anonymous says:
Regarding Unix/Linux, it would be nice to easily find a start/stop script to dep...Regarding Unix/Linux, it would be nice to easily find a start/stop script to deploy under /etc/rc* so it is ensured Hudson starts after a reboot.
Jan 09, 2008
Anonymous says:
I used a simple script in /etc/rc.d/init.d in conjuction with the Fedora "chkcon...I used a simple script in /etc/rc.d/init.d in conjuction with the Fedora "chkconfig" command to create a linux service. Here's the script including the chkconfig parms included as comments. Do a "man ckkconfig" for more details on chkconfig. #!/bin/bash # # hudson This shell script starts the Hudson continuous integration # service. # # chkconfig: 2345 64 36 # description: The Hudson CI server # processname: mysqld java -jar /root/hudson/hudson.war --httpPort=18080 --ajp13Port=18009 >/root/huds on/hudson.log 2>&1
Jan 10, 2008
Anonymous says:
I've made some minor and not so minor changes to the above init.d script here's ...I've made some minor and not so minor changes to the above init.d script - here's the new (and more readable) version:
Jan 27, 2008
Anonymous says:
Here's an even more elaborate init.d script: #!/bin/bash # # Startup script for...Here's an even more elaborate init.d script:
#!/bin/bash # # Startup script for Hudson # # chkconfig: - 84 16 # description: Hudson CI server # Source function library. . /etc/rc.d/init.d/functions [ -z "$JAVA_HOME" -a -x /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh HUDSON_HOME=/var/hudson WAR="$HUDSON_HOME/hudson.war" LOG="/var/log/hudson.log" LOCK="/var/lock/subsys/hudson" export HUDSON_HOME RETVAL=0 pid_of_hudson() { ps auxwww | grep java | grep hudson | grep -v grep | awk '{print $2}' } start() { [ -e "$LOG" ] && cnt=`wc -l "$LOG" | awk '{ print $1 }'` || cnt=1 echo -n $"Starting hudson: " cd "$HUDSON_HOME" nohup java -jar "$WAR" --httpPort=-1 --ajp13Port=8010 --prefix=/hudson >> "$LOG" 2>&1 & while { pid_of_hudson > /dev/null ; } && ! { tail +$cnt "$LOG" | grep -q 'Winstone Servlet Engine .* running' ; } ; do sleep 1 done pid_of_hudson > /dev/null RETVAL=$? [ $RETVAL = 0 ] && success $"$STRING" || failure $"$STRING" echo [ $RETVAL = 0 ] && touch "$LOCK" } stop() { echo -n "Stopping hudson: " pid=`pid_of_hudson` [ -n "$pid" ] && kill $pid RETVAL=$? cnt=10 while [ $RETVAL = 0 -a $cnt -gt 0 ] && { pid_of_hudson > /dev/null ; } ; do sleep 1 ((cnt--)) done [ $RETVAL = 0 ] && rm -f "$LOCK" [ $RETVAL = 0 ] && success $"$STRING" || failure $"$STRING" echo } status() { pid=`pid_of_hudson` if [ -n "$pid" ]; then echo "hudson (pid $pid) is running..." return 0 fi if [ -f "$LOCK" ]; then echo $"${base} dead but subsys locked" return 2 fi echo "hudson is stopped" return 3 } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ;; restart) stop start ;; *) echo $"Usage: $0 {start|stop|restart|status}" exit 1 esac exit $RETVALJul 11, 2008
Stefan Groschupf says:
Attention this script at least in my case overwrote the PATH variable, what caus...Attention this script at least in my case overwrote the PATH variable, what caused my perforce plugin to not find the p4 executable.
So you want to add a line in the script to add the p4 executables to the path again.
Feb 26, 2008
Anonymous says:
To Anon of the Jan 27 2008 post : That script works great, thanks for that...To Anon of the Jan 27 2008 post :
That script works great, thanks for that
G
Jun 12
Mark Wolff says:
I have hudson running as a widows service and now I need to change the port numb...I have hudson running as a widows service and now I need to change the port number. On previous installs, I fixed this before I set up the windows service. Can I change the port number now?