Error   test

Solr Chkconfig and start/stop scripts

Posted July 9, 2007 at 10:07pm in Computers, Programming

These are very simple, there is no check to see if it is running and no error handling. This is my first chkconfig script and I am not bash brilliant.

*Note: The syntax highligher is replacing the double dashes (–) in the solr.stop script so please click the “Show Plain Code” when copying. I will find the bug in the script to avoid having to do that.

In /etc/init.d/solr

  1. #!/bin/bash
  2. #
  3. # chkconfig: - 80 45
  4. # description: Starts and stops Solr
  5.  
  6. start() {
  7.         echo -n "Starting Solr… "
  8.         nohup /opt/directory/solr.start
  9.         echo "OK"
  10.         return 0
  11. }
  12.  
  13. stop() {
  14.         echo -n "Stopping Solr… "
  15.         /opt/directory/solr.stop
  16.         echo "OK"
  17.         return 0
  18. }
  19.  
  20. case "$1" in
  21.   start)
  22.         start
  23.         ;;
  24.   stop)
  25.         stop
  26.         ;;
  27.   restart)
  28.         stop
  29.         start
  30.         ;;
  31.   *)
  32.         echo $"Usage: $0 {start|stop|restart}"
  33.         exit 1
  34. esac
  35.  
  36. exit $?

This is the /opt/directory/solr.start file

  1. #!/bin/bash
  2. cd /opt/directory/
  3. /usr/java/jdk1.6.0_01/bin/java -DSTOP.PORT=8079 -DSTOP.KEY=ftasolrstop -jar start.jar &

This is the /opt/directory/solr.stop file

  1. #!/bin/bash
  2. cd /opt/directory/
  3. /usr/java/jdk1.6.0_01/bin/java -DSTOP.PORT=8079 -DSTOP.KEY=ftasolrstop -jar start.jar –stop
  • Google
  • del.icio.us
  • Digg
  • Spurl
  • Facebook


Leave a Reply