Solr init script

An init script to start up, stop, and restart Solr.

I cobbled together the following init script for Solr, using the Jetty it comes with, with a little help from various other init.d scripts and Pete's example:

#!/bin/sh -e

# Starts, stops, and restarts solr

SOLR_DIR="/usr/local/solr/example"
JAVA_OPTIONS="-Xmx1024m -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -jar start.jar"
LOG_FILE="/var/log/solr.log"
JAVA="/usr/bin/java"

case $1 in
    start)
        echo "Starting Solr"
        cd $SOLR_DIR
        $JAVA $JAVA_OPTIONS 2> $LOG_FILE &
        ;;
    stop)
        echo "Stopping Solr"
        cd $SOLR_DIR
        $JAVA $JAVA_OPTIONS --stop
        ;;
    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}" >&2
        exit 1
        ;;
esac
keywords: Solr, init, init.d, start, stop, restart created 2008-05-30 last modified 2010-09-13