Launchd & Tomcat
Launchd is amazing. It's predictable, simple, easy and correct. When Apple makes an app like Launchd in 2005, it makes me wonder what the hell Sun, HP and IBM were doing while improving UNIX for the last 30 years. Regardless it's my new favourite thing and it's much better than init.d and the Windows services system.To get Tomcat started when your Mac boots, create a file called /Library/LaunchDaemons/org.apache.jakarta.tomcat.plist and fill it with the following XML. You'll need to change the paths to your Tomcat folder and use the Mac OS X user that Tomcat shall run as.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http:// www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Tomcat Startup Script, by Jesse Wilson, May 27, 2005 -->
<plist version="1.0">
<dict>
<key>Label</key> <string>org.apache.jakarta.tomcat</string>
<key>OnDemand</key> <false/>
<key>ProgramArguments</key> <array>
<string>/Users/jessewilson/Apps/jakarta-tomcat-5.5.9/bin/catalina.sh</string>
<string>run</string>
</array>
<key>ServiceDescription</key> <string>Tomcat Server</string>
<key>UserName</key> <string>jessewilson</string>
<key>StandardOutPath</key> <string>/Users/jessewilson/Apps/jakarta-tomcat-5.5.9/log.stdout</string>
<key>StandardErrorPath</key> <string>/Users/jessewilson/Apps/jakarta-tomcat-5.5.9/log.stderror</string>
<key>EnvironmentVariables</key> <dict>
<key>JAVA_HOME</key>
<string>/System/Library/Frameworks/JavaVM.framework/Home</string>
</dict>
</dict>
</plist>