Skip to content

Instantly share code, notes, and snippets.

@anon5r
Created August 7, 2012 06:55
Show Gist options
  • Save anon5r/3282520 to your computer and use it in GitHub Desktop.
Save anon5r/3282520 to your computer and use it in GitHub Desktop.
Start Daemon for Apache Solr Searcher
#!/bin/sh
#
# chkconfig: - 90 20
# description: apache-solr
#
if [ -f /etc/rc.d/init.d/functions ]; then
# Source function library.
. /etc/rc.d/init.d/functions
elif [ -f /etc/rc.status ]; then
. /etc/rc.status
alias success='rc_status -v'
alias failure='rc_status -v'
fi
# Variables
prog=Solr
#SEN_HOME=/opt/sen
SOLR_HOME=/usr/local/apache-solr
JAVA_HOME=/usr
LOCKFILE=/var/lock/subsys/solr
SOLR_PROJECT=seacher
JAVA_STOP_PORT=8079
JAVA_OPTIONS=" -DSTOP.PORT=${JAVA_STOP_PORT} -DSTOP.KEY=stopkey -Xmx2048M -Xms2048M -Xmn512M -XX:NewSize=274m -XX:MaxNewSize=274m -XX:SurvivorRatio=2 -XX:PermSize=218M -XX:MaxPermSize=218M"
start() {
[ -e ${LOCKFILE}-${SOLR_PROJECT} ] && echo "Solr \"${SOLR_PROJECT}\" is already running." && failure && echo && return 1;
echo -n "Starting $prog... "
cd $SOLR_HOME/$SOLR_PROJECT
#$JAVA_HOME/bin/java -jar start.jar >& /var/log/solr-${SOLR_PROJECT}.log &
#$JAVA_HOME/bin/java -Xmx2048M -Xms2048M -Xmn512M -XX:NewSize=274m -XX:MaxNewSize=274m -XX:SurvivorRatio=2 -XX:PermSize=218M -XX:MaxPermSize=218M -jar start.jar >& /var/log/solr-${SOLR_PROJECT}_`date +"%Y-%m-%d"`.log &
$JAVA_HOME/bin/java $JAVA_OPTIONS -jar start.jar 2>&1 | /usr/local/sbin/cronolog /var/log/solr-${SOLR_PROJECT}_%Y-%m-%d.log >> /dev/null &
#$JAVA_HOME/bin/java -Xmx2048M -Xmn512M -jar start.jar >& /var/log/solr-${SOLR_PROJECT}.log &
#$JAVA_HOME/bin/java -Xmx512M -Xmn256M -Dsolr.solr.home=multicore -jar start.jar >& /var/log/solr-${SOLR_PROJECT}.log &
RETVAL=$?
[ $RETVAL -ne 0 ] && failure && return $RETVAL
[ $RETVAL -eq 0 ] && touch "${LOCKFILE}-${SOLR_PROJECT}" && success
echo
return $RETVAL
}
stop() {
echo -n "Stopping $prog... "
#killproc java
$JAVA_HOME/bin/java $JAVA_OPTIONS -jar start.jar --stop
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCKFILE}-${SOLR_PROJECT}
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
status)
status java
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
;;
esac
# End /etc/init.d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment