Created
February 25, 2011 13:02
-
-
Save pioz/843754 to your computer and use it in GitHub Desktop.
init.d script to run solr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PATH=/opt/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
NAME=solr | |
DESC=apache-solr | |
VERSION=1.4.1 | |
SOLR_PATH=/opt/solr-$VERSION | |
COMMAND=/usr/bin/java | |
OPTIONS="-Dsolr.solr.home=$SOLR_PATH/solr -Djetty.home=$SOLR_PATH -jar $SOLR_PATH/start.jar" | |
PIDFILE=/var/run/$NAME.pid | |
test -x $COMMAND || exit 0 | |
test -f $DAEMON || exit 0 | |
set -e | |
case "$1" in | |
start) | |
if [ -f $PIDFILE ]; then | |
echo "$PIDFILE exists. $NAME may be running." | |
else | |
echo -n "Starting $DESC: " | |
start-stop-daemon -b -p$PIDFILE -d$SOLR_PATH --start --quiet --exec $COMMAND -- $OPTIONS | |
sleep 3 | |
echo `ps -ef | grep -v grep | grep "$COMMAND $OPTIONS" | awk '{print $2}'` > $PIDFILE | |
echo "$NAME." | |
fi | |
;; | |
stop) | |
if [ -f $PIDFILE ]; then | |
echo -n "Stopping $DESC: " | |
kill `cat $PIDFILE` | |
rm -f $PIDFILE | |
echo "$NAME." | |
else | |
echo "$PIDFILE does not exist. $NAME may be not running." | |
fi | |
;; | |
restart) | |
/etc/init.d/$NAME stop | |
sleep 1 | |
/etc/init.d/$NAME start | |
;; | |
*) | |
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment