-
-
Save neilellis/5595667 to your computer and use it in GitHub Desktop.
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/bash | |
# init script for Cassandra. | |
# chkconfig: 2345 90 10 | |
# description: Cassandra | |
# script slightly modified from | |
# http://blog.milford.io/2010/06/installing-apache-cassandra-on-centos/ | |
. /etc/rc.d/init.d/functions | |
CASS_HOME=/cassandra/apache-cassandra-1.2.4 | |
CASS_BIN=$CASS_HOME/bin/cassandra | |
CASS_LOG=$CASS_HOME/../log/system.log | |
CASS_USER="root" | |
CASS_PID=/var/run/cassandra.pid | |
if [ ! -f $CASS_BIN ]; then | |
echo "File not found: $CASS_BIN" | |
exit 1 | |
fi | |
RETVAL=0 | |
start() { | |
if [ -f $CASS_PID ] && checkpid `cat $CASS_PID`; then | |
echo "Cassandra is already running." | |
exit 0 | |
fi | |
echo -n $"Starting $prog: " | |
daemon --user $CASS_USER $CASS_BIN -p $CASS_PID >> $CASS_LOG 2>&1 | |
usleep 500000 | |
RETVAL=$? | |
if [ "$RETVAL" = "0" ]; then | |
echo_success | |
else | |
echo_failure | |
fi | |
echo | |
return $RETVAL | |
} | |
stop() { | |
# check if the process is already stopped by seeing if the pid file exists. | |
if [ ! -f $CASS_PID ]; then | |
echo "Cassandra is already stopped." | |
exit 0 | |
fi | |
echo -n $"Stopping $prog: " | |
if kill `cat $CASS_PID`; then | |
RETVAL=0 | |
echo_success | |
else | |
RETVAL=1 | |
echo_failure | |
fi | |
echo | |
[ $RETVAL = 0 ] | |
} | |
status_fn() { | |
if [ -f $CASS_PID ] && checkpid `cat $CASS_PID`; then | |
echo "Cassandra is running." | |
exit 0 | |
else | |
echo "Cassandra is stopped." | |
exit 1 | |
fi | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status_fn | |
;; | |
restart) | |
stop | |
usleep 500000 | |
start | |
;; | |
*) | |
echo $"Usage: $prog {start|stop|restart|status}" | |
RETVAL=3 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment