Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Hudson-ci/HudsonLinuxStartupScript

Hudson Continuous Integration Server
Website
Download
Community
Mailing ListForumsIRCmattermost
Issues
OpenHelp WantedBug Day
Contribute
Browse Source
Hudson-bust.png Startup Script For Linux











This is a startup script for Linux, and provides start/stop/restart functionality. This has been tested on Ubuntu, but should work on other Linuxes like Redhat or SuSE. You may need to change the environment variables at the top of the script to fit your system. This assumes that hudson is installed in /home/hudson, tomcat is installed in /home/hudson/apache-tomcat-6.0.18, and that HUDSON_HOME is /home/hudson/hudson-home

#!/bin/sh
#
# Startup script for the Hudson Continuous Integration server
# (via Jakarta Tomcat Java Servlets and JSP server)
#
# chkconfig: - 85 15
# description: Jakarta Tomcat Java Servlets and JSP server
# processname: tomcat
# pidfile: /var/run/tomcat.pid

# Set Tomcat environment.
HUDSON_USER=hudson
LOCKFILE=/var/lock/hudson
export PATH=/usr/local/bin:$PATH
export HOME=/home/hudson
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export HUDSON_BASEDIR=/home/hudson
export TOMCAT_HOME=$HUDSON_BASEDIR/apache-tomcat-6.0.18
export CATALINA_PID=$HUDSON_BASEDIR/hudson-tomcat.pid
export CATALINA_OPTS="-DHUDSON_HOME=$HUDSON_BASEDIR/hudson-home -Xmx512m -Djava.awt.headless=true"

[ -f $TOMCAT_HOME/bin/catalina.sh ] || exit 0

export PATH=$PATH:/usr/bin:/usr/local/bin

# See how we were called.
case "$1" in
  start)
        # Start daemon.
        echo -n "Starting Tomcat: "
        su -p -s /bin/sh $HUDSON_USER -c "$TOMCAT_HOME/bin/catalina.sh start"
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch $LOCKFILE
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down Tomcat: "
        su -p -s /bin/sh $HUDSON_USER -c "$TOMCAT_HOME/bin/catalina.sh stop"
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f $LOCKFILE
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  condrestart)
       [ -e $LOCKFILE ] && $0 restart
       ;;
  status)
        status tomcat
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
esac

exit 0

To install, on Ubuntu

  • save the file to /etc/init.d/hudson
  • chmod a+x /etc/init.d/hudson
  • update-rc.d hudson defaults


To install, on Red Hat

  • save the file to /etc/init.d/hudson
  • chmod a+x /etc/init.d/hudson
  • chkconfig hudson on
  • ntsysv and see if the hudson service is turned on.

Back to the top