Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. Bessere Alternative
  2.  
  3. 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.
  4.  
  5. echo "ENABLED=1" > /etc/default/tomcat
  6.  
  7. Then the script itself.
  8.  
  9. vim /etc/init.d/tomcat
  10.  
  11. Put the following in the tomcat file.
  12.  
  13. # Tomcat auto-start
  14. #
  15. # description: Auto-starts tomcat
  16. # processname: tomcat
  17. # pidfile: /var/run/tomcat.pid
  18. ENABLED=0
  19.  
  20. if [ -f /etc/default/tomcat ]; then
  21.   . /etc/default/tomcat
  22. fi
  23.  
  24. if [ "$ENABLED" = "0" ]; then
  25.   exit 0
  26. fi
  27.  
  28. export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
  29. export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/opt/solr"
  30. export CATALINA_OPTS="-Xms64m -Xmx64m"
  31.  
  32. case $1 in
  33. start)
  34.   sh /opt/tomcat/bin/startup.sh
  35.   ;;
  36. stop)
  37.   sh /opt/tomcat/bin/shutdown.sh
  38.   ;;
  39. restart)
  40.   sh /opt/tomcat/bin/shutdown.sh
  41.   sh /opt/tomcat/bin/startup.sh
  42.   ;;
  43. esac
  44. exit 0
  45.  
  46. 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.
  47.  
  48. -Xms[size] set initial Java heap size
  49. -Xmx[size] set maximum Java heap size
  50.  
  51. 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.
  52.  
  53. chmod 755 /etc/init.d/tomcat
  54. update-rc.d tomcat defaults
  55.  
  56. Now we can start Apache Tomcat and Solr with this command. (On reboots it will automatically start.)
  57.  
  58. invoke-rc.d tomcat start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement