-
-
Save joeymink/5808619 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| description "Tomcat Server" | |
| start on runlevel [2345] | |
| stop on runlevel [!2345] | |
| respawn | |
| respawn limit 10 5 | |
| # run as non privileged user | |
| # add user with this command: | |
| ## adduser --system --ingroup www-data --home /opt/apache-tomcat apache-tomcat | |
| # Ubuntu 12.04: (use 'exec sudo -u apache-tomcat' when using 10.04) | |
| setuid apache-tomcat | |
| setgid www-data | |
| # adapt paths: | |
| env JAVA_HOME=/opt/java | |
| env CATALINA_HOME=/opt/apache-tomcat | |
| # adapt java options to suit your needs: | |
| env JAVA_OPTS="-Djava.awt.headless=true -Xms512M -Xmx1024M -server -XX:+UseParallelGC" | |
| exec $CATALINA_HOME/bin/catalina.sh run | |
| # cleanup temp directory after stop | |
| post-stop script | |
| rm -rf $CATALINA_HOME/temp/* | |
| end script |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1 Drop this into /etc/init on an ubuntu instance
2 Run the adduser command in the comments (note that it assumes tomcat is installed in /opt/apache-tomcat)
3 Ensure CATALINA_HOME is correct (same location as the previous step's home)
4 Ensure JAVA_HOME is correct (might be /usr/lib/java/... if you're using OpenJDK)