| Installing Hudson as a service on Redhat |
|
|
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? In this article, we look at a few options you might consider if you need to install Hudson on a Redhat box. 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! Trackback(0)
Comments (3)
![]() written by ampur, July 01, 2010
Hi,
I was reading your article & being a limited knowledge in Unix, I just would like to know, the reason of having a separate "hudson" user (adduser -m -s /bin/bash hudson ). Is there any security issue is related, if we dont create a separate user rather than configure as "root" user? As I am working on an installer project for a in-house Java Server gateway, Shall I also create some new user say "gateway" to run as a different user? Will other user also be able to use the service? Thanks. written by John Smart, July 02, 2010
Thanks for your question.
For security reasons, it is generally not recommended to have any server application running under root. In Hudson, for example, you can run command-line scripts - letting users run these as root would be a very high security risk. Running Hudson as a dedicated user also makes it easier to keep track of the resources the Hudson server is using, and so forth. - John. Write comment
|
Agile ALL Annotations Artifactory Automated Deployment Automated Testing BDD Bugzilla Build Automation Cargo Checkstyle Code Coverage Code Quality Code Reviews Continuous Integration Continuum Distributed Builds EasyB Eclipse Grails Groovy Hibernate Hudson Humour Integration Tests JasperReports Java Javascript JDave JUnit Lucene Maven Mock Objects Mockito Mylyn Nexus Performance Profiling Rome RSS Selenium Smack API Subversion TDD TeamCity Testing Trac training Unit Testing Unit Tests
You might want to state to set the permissions properly on the start and stop scripts by either creating them via the hudson user or changing the owner/group on them.