Skip to content

Instantly share code, notes, and snippets.

@libinbensin
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save libinbensin/1450310d84fa797890aa to your computer and use it in GitHub Desktop.
Save libinbensin/1450310d84fa797890aa to your computer and use it in GitHub Desktop.
Start Apache Tomcat at boot on Mac OS X
This is for installing tomcat as a daemon on port 8080 but enable also port 80 by using a firewall redirection.
Edit /Library/Tomcat/conf/server.xml and add proxyport="80" URIEncoding="UTF-8" inside <Connector .../>.
<Connector proxyport="80" URIEncoding="UTF-8" />
Assign enough memory to the Java machine or you may be in trouble later. Inside /Library/Tomcat/conf/local.env
export JAVA_JVM_VERSION=CurrentJDK
export JAVA_OPTS="-Xmx3000M -Xms3000M -Djava.awt.headless=true -Duser.timezone=UTC"
In my example I allocated ~3Gb or RAM but you can adapt this, anyway don't put less than 1GB if you are running hudson inside tomcat.
Running as a service
Run sudo nano /Library/LaunchDaemons/org.apache.tomcat.plist and paste the code below:
<?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">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>org.apache.tomcat</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Tomcat/bin/catalina.sh</string>
<string>run</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Check that launchd detected you new daemon, if not reboot :(
launchctl list|grep tomcat
Start tomcat manually.
launchctl start org.apache.tomcat
If the status is something else than -, you have a problem and you should investigate it: launchctl log level debug and check /var/log/system.log.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment