Browse Source

bigcouch init

4.0
karl anderson 10 years ago
parent
commit
a97fab6593
1 changed files with 92 additions and 0 deletions
  1. +92
    -0
      system/init.d/kazoo-bigcouch.redhat

+ 92
- 0
system/init.d/kazoo-bigcouch.redhat View File

@ -0,0 +1,92 @@
#!/bin/bash
#
# BigCouch
#
# chkconfig: 345 13 87
# description: BigCouch is a dynamo-style distributed database based on Apache CouchDB.
# processname: bigcouch
# pidfile: /var/run/bigcouch.pid
#
# Source function library.
. /etc/init.d/functions
if [ -f /etc/sysconfig/bigcouch ]; then
. /etc/sysconfig/bigcouch
fi
prog="bigcouch"
lockfile=${LOCKFILE-/var/lock/subsys/kazoo-bigcouch}
user="bigcouch"
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
# Check that networking is up.
if [ "$NETWORKING" = "no" ]; then
exit 0
fi
[ -f /usr/bin/bigcouch ] || exit 0
# Detect core count
CORES=`grep -E "^processor" /proc/cpuinfo |wc -l`
if [ "$CORES" = "1" ]; then
BEAM=beam
else
BEAM=beam.smp
fi
start() {
echo -n $"Starting ${prog}: "
export HOME=/srv
cd $HOME
daemon --user=${user} "/usr/bin/${prog} >/dev/null &"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
RETVAL=-1
echo -n $"Stopping $prog: "
for i in `pidof $BEAM`; do
if cat /proc/$i/cmdline | grep -Eq "name[^\-]+bigcouch"; then
kill $i
RETVAL=$?
fi
done
echo
[ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile}
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -l ${lockfile} \$BEAM
RETVAL=$?
;;
restart|reload)
restart
;;
condrestart)
[ ! -e ${lockfile} ] && restart
;;
*)
echo $"Usage: $0 (start|stop|restart|status)"
exit 1
esac
exit $?

Loading…
Cancel
Save