Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Bessere Alternative
- I like the Debian system of having a file in ?/etc/default? with a simple ENABLED setting. With this you can easily enable/disable a service. If you for some reason want do disable Tomcat/Solr you just set ?ENABLED=0? and the service will not autostart.
- echo "ENABLED=1" > /etc/default/tomcat
- Then the script itself.
- vim /etc/init.d/tomcat
- Put the following in the tomcat file.
- # Tomcat auto-start
- #
- # description: Auto-starts tomcat
- # processname: tomcat
- # pidfile: /var/run/tomcat.pid
- ENABLED=0
- if [ -f /etc/default/tomcat ]; then
- . /etc/default/tomcat
- fi
- if [ "$ENABLED" = "0" ]; then
- exit 0
- fi
- export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
- export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/opt/solr"
- export CATALINA_OPTS="-Xms64m -Xmx64m"
- case $1 in
- start)
- sh /opt/tomcat/bin/startup.sh
- ;;
- stop)
- sh /opt/tomcat/bin/shutdown.sh
- ;;
- restart)
- sh /opt/tomcat/bin/shutdown.sh
- sh /opt/tomcat/bin/startup.sh
- ;;
- esac
- exit 0
- The CATALINA_OPTS parameter controls how much RAM Tomcat is. The default was to high for my VPS so I set it down to 64 MB. I have not investigated what the optimum is here but it seems works for my small site at least.
- -Xms[size] set initial Java heap size
- -Xmx[size] set maximum Java heap size
- Make the script executable and add the appropriate symbolic links to cause the script to be executed when the system goes down, or comes up.
- chmod 755 /etc/init.d/tomcat
- update-rc.d tomcat defaults
- Now we can start Apache Tomcat and Solr with this command. (On reboots it will automatically start.)
- invoke-rc.d tomcat start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement