Search |
||
Installing Hudson as a service on RedhatPosted by johnsmart on October 8, 2008 at 2:48 AM PDT
Hudson is a great little Continuous Integration server. One of Kosuke's more recent innovations has been to add a feature that lets you install Hudson as a service on Windows. A very useful feature indeed, as previously this was a fairly non-trivial operation. But what if you're running Hudson on a Linux server? Now there are a few ways to do this. One possibility for example is to install Tomcat as a service and then deploy Hudson onto this server. There is plenty of documentation on the internet about how to install Tomcat as a service on a linux machine. But what if you don't like Tomcat? What if your quite happy with Hudson's built in web server, and can't be bothered setting up Tomcat on your server? You can by all means set up Hudson as a service by itself, and it isn't hard to do. A few techniques are documented on the Hudson web site. I recently went through the process on a Redhat linux machine, which is a little different from the examples on the side. So, for the record, here is a short rundown on how I did it. First of all, it's a good idea to have a dedicated hudson user. You can create one in the standard Unix fashion, as shown here:
Next, you need to download the hudson.war file and place in in an appropriate directory. I put mine in /usr/share/hudson.
You can create simple start and stop scripts for Hudson as shown below. The start script (which I place in /usr/local/bin/start-hudson.sh) looks like this:
The stop script (/usr/local/bin/stop-hudson.sh) is a fairly basic one, as shown here:
Next, to make your installation a little cleaner, you can write a simple init script to start and stop Hudson using these scripts. The following is a very basic example, which starts and stops Hudson, and runs Hudson as the 'hudson' user (running Hudson as root is not a good idea):
Place this script in the /etc/init.d directory (e.g. /etc/init.d/hudson), and make it executable.
Now you can start and stop Hudson in a familiar Unix fashion:
Finally, you can set this up to start and stop when the server reboots, by placing links in the appropriate run level directories. The easy way to do this is to use the chkconfig command, as shown here:
And now, you should be good to go! "One of the best and most useful courses I have attended...Best development course I have been on in a very long time...A 'must' course for serious Java developers..." - Read what people are saying about the Java Power Tools Bootcamps. »
Comments
Comments are listed in date ascending order (oldest first)
Submitted by pbleser on Wed, 2008-10-08 14:58.
There are more accurate (but slightly more complex) ways to accomplish that, especially wrt finding the PID of the java process.
Have a look at how I implemented that in my hudson.init script for openSUSE:
http://linux01.gwdg.de/~pbleser/files/rpm/hudson/hudson.init.in
(same trick is applicable to other Linux distros too)
Submitted by candrews on Thu, 2008-10-09 04:52.
Why not just using your distributions tomcat/jetty/jboss or whatever other Java container support, and run the hudson war in it? It's much easier, and you end up with the same result.
Submitted by johnsmart on Thu, 2008-10-09 05:00.
One reason you might prefer the built-in (Winstone) embedded server over something like Tomcat or JBoss is memory footprint . I haven't got hard, scientific figures, but running Hudson on Tomcat certainly requires (quite a bit) more memory than running Hudson by itself.
|
||
|
|