Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Hudson as a service on OS X?

Running hudson it is easy but currently the documentation is missing the tutorial for installing an running hudson as a daemon/service on OS X.

When you switch to production you need to assure that it is properly configured and secured.

Requirements:

  • be able to run it on port 80
  • not running as root (or at least not running the jobs as root)
  • assure that it does properly start/stop on system restarts
  • enable auto-upgrade, that works directly from the web interface.

The best, would be to have an installation script that downloads latest hudson and installs it.

We'll integrate the best answer to Hudson wiki.

Resources:

  • http://wiki.hudson-ci.org/display/HUDSON/Meet+Hudson
  • http://wiki.hudson-ci.org/display/HUDSON/Automated+Upgrade
  • http://jrenard.info/blog/a-quick-but-working-startup-item-for-hudson-for-mac-os-x.html
  • http://wiki.hudson-ci.org/display/HUDSON/Installing+Hudson+as+a+Unix+daemon
  • http://weblogs.java.net/blog/2009/02/10/hudson-now-good-behaving-unix-daemon
like image 868
sorin Avatar asked Sep 15 '10 07:09

sorin


People also ask

How do I install a service on a Mac?

The simplest way to install a single Service is to double-click it in Finder. Finder will show a dialog asking if you want to install the Service. Just hit “Install” to add it to your Services menu. You can also move the files into your Services folder manually.

How do I install Hudson on Windows?

Install Hudson as a Windows serviceOnce Hudson is started, click the manage Hudson link and look for the "Install as Windows Service" link on the management page. Choose the directory where Hudson shall be installed (the directory must already exist).


1 Answers

If you want a local Hudson to run on your Mac whenever you log in, try this.

You'll want to set up a launchctl plist for it; that should look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>UserName</key>
 <string>yourid</string>
 <key>Label</key>
 <string>Hudson</string>
 <key>EnvironmentVariables</key>
   <dict>
     <key>HUDSON_HOME</key>
     <string>/Users/yourid/.hudson</string>
   </dict>
 <key>ProgramArguments</key>
 <array>
 <string>/usr/bin/java</string>
 <string>-jar</string>
 <string>/Users/yourid/Hudson/hudson.war</string>
 </array>
 <key>RunAtLoad</key>
 <true/>
</dict>
</plist>

This assumes you've downloaded hudson.war to your home directory under ~/Hudson, and that you want to run it as yourself (probably the best decisions.) Be sure that you define the <UserName> key or it will run as root!

Starting on login

  1. Save the above as /Library/LaunchAgents/hudson.plist
  2. Start it the first time with

    sudo launchctl load -w /Library/LaunchAgents/hudson.plist

or log out and back in, which will do the same thing automatically.

Starting on reboot

  1. Save the above as /Library/LaunchDaemons/hudson.plist
  2. Start it the first time with

    sudo launchctl load -w /Library/LaunchDaemons/hudson.plist

or reboot your machine, which will do the same thing automatically.

Restarting Hudson

Hudson can't automatically restart under OS X, so if you need to stop it, issue the restart command

launchctl unload -w path_to_plist

I have found that sometimes it doesn't stop on the first execution of launchctl unload; in those cases just issue the command again.

This will run under port 8080 as if you had run the command from the command line yourself, using the Winstone server built in to the .war file.

I realize this doesn't specifically answer the "run it on port 80" question, but for development on your own laptop, I suggest that this is a better option.

like image 99
Joe McMahon Avatar answered Oct 06 '22 18:10

Joe McMahon