Auto-Restart Hudson when it fails

How to Automatically Restart Hudson with Service Protector

Monitor the Hudson Windows Service and keep your continuous integration running smoothly, even in the face of failure.

Hudson is a java-based continuous integration tool. It can be installed as a Windows Service for 24/7 operation, without a user having to be logged on:


To protect the Hudson Windows Service with Service Protector:

  1. Download and install Service Protector, if necessary.

  2. Start Service Protector.

  3. Select Protector > Add to open the Add Protector window:

    Add Protector

  4. On the General tab, select the Hudson service in the Service to protect pull-down list.

    Hudson Windows Service: General Tab

  5. If you are interested in monitoring Hudson and detecting when it stops responding to HTTP requests (or returns a 5XX error), click over to the Monitor tab where we'll set up a failure detection script to tell Service Protector when Hudson has run into trouble.

    1. Follow these instructions to create the failure detection BAT file. We have called ours check-hudson.bat and placed it in the Hudson installation folder, C:\Hudson.

    2. Check the Whenever it fails a "sanity check" box and click the "..." button to open the Configure Sanity Check window. Enter the full path to the batch file, enclosing the whole value in quotes if it contains a space.

      The default to check every 30 seconds is probably overkill, so change the Every controls to 5 minutes. Of course you can adjust this frequency as you see fit!

      Press the OK button to save your sanity check settings.

    Hudson Windows Service: Monitor Tab

  6. We're now done configuring Hudson so click the Save button to save the settings. In a couple of seconds, an entry called hudson will show up in the Service Protector window. Hudson is probably already running but it is not yet being protected by Service Protector, as shown here:

    Hudson Windows Service: Created

  7. To start monitoring and protecting Hudson, choose Protector > Start "hudson". The shield icon will go to green to indicate that Hudson is being protected by Service Protector.

    At any time, click on the green shield to show a popup indicating when protection started, or click on the green circle to see information on the service itself:

    Hudson Windows Service: Running

  8. That's it! Next time your computer boots, Hudson will start as normal and Service Protector will begin monitoring the service to promptly restart it if it fails or stops for any reason.

    We encourage you to edit Hudson in Service Protector and check out the many other settings that may be appropriate for your environment. For example, send an email when the service fails, restart Hudson during the wee hours to minimize memory leaks, restart Hudson if it uses too much RAM, etc.



Trouble protecting the Hudson Windows Service?