Skip to content

Instantly share code, notes, and snippets.

@alexandrerocco
Created June 21, 2013 21:33
Show Gist options
  • Save alexandrerocco/5834500 to your computer and use it in GitHub Desktop.
Save alexandrerocco/5834500 to your computer and use it in GitHub Desktop.
Init Script for Apache Solr
#!/bin/sh -e
# chkconfig: 2345 95 20
# description: Solr Server
# Solr Server service start, stop, restart
# @author Shay Alexandre Rocco
SOLR_DIR="/opt/solr"
JAVA="/usr/bin/java -Xmx256m -DSTOP.PORT=8079 -DSTOP.KEY=a09df7a0d -jar start.jar"
case $1 in
start)
echo "Starting Solr..."
cd $SOLR_DIR
# this will run server and SUPPRESS output/error messages
$JAVA 1>/dev/null 2>/dev/null &
# this will run server and DISPLAY output/error messages
#$JAVA &
sleep 3
;;
stop)
echo "Stopping Solr..."
cd $SOLR_DIR
$JAVA --stop 2>/dev/null
sleep 3
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage: $0 [start|stop|restart]"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment