Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
initscript for mongodb
#! /bin/sh
# start / stop script for mongodb
#
# mongodb - this script starts and stops the mongo daemon
#
# chkconfig: - 85 15
# description: Mongodb
# processname: mongod
# config: /etc/sysconfig/mongodb
# pidfile: /var/run/mongod.pid
. /etc/init.d/functions
# Source function library.
#. /lib/lsb/init-functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
retval=0
pidfile=/var/run/mongod.pid
exec="/usr/local/bin/mongod"
prog="mongod"
[ -f /etc/sysconfig/mongodb ] && . /etc/sysconfig/mongodb
start() {
[ -x $exec ] || exit 5
echo "Starting mongoDB daemon"
daemon --pidfile pidfile --user $MONGO_USER \
"$exec $MONGO_OPTS run" >> /var/log/mongodb.log 2>&1 &
return $?
}
stop() {
echo "Stopping mongoDB daemon"
killproc -d 10 $exec
return $?
}
restart() {
stop
start
}
reload() {
restart
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
exit 2
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.