2009-12-03 20:20:35 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# mongod - Startup script for mongod
|
|
|
|
|
|
|
|
# chkconfig: 35 85 15
|
|
|
|
# description: Mongo is a scalable, document-oriented database.
|
|
|
|
# processname: mongod
|
|
|
|
# config: /etc/mongod.conf
|
|
|
|
# pidfile: /var/run/mongo/mongo.pid
|
|
|
|
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
# things from mongod.conf get there by mongod reading it
|
|
|
|
|
2010-03-16 15:05:32 +01:00
|
|
|
|
|
|
|
|
2009-12-03 20:20:35 +01:00
|
|
|
OPTIONS=" -f /etc/mongod.conf"
|
2010-03-16 15:05:32 +01:00
|
|
|
SYSCONFIG="/etc/sysconfig/mongod"
|
2009-12-03 20:20:35 +01:00
|
|
|
|
|
|
|
mongod=${MONGOD-/usr/bin/mongod}
|
2010-03-16 15:05:32 +01:00
|
|
|
|
|
|
|
MONGO_USER=mongod
|
|
|
|
MONGO_GROUP=mongod
|
|
|
|
|
|
|
|
. "$SYSCONFIG" || true
|
2009-12-03 20:20:35 +01:00
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
|
|
|
echo -n $"Starting mongod: "
|
2010-03-16 15:05:32 +01:00
|
|
|
daemon --user "$MONGO_USER" $mongod $OPTIONS
|
2009-12-03 20:20:35 +01:00
|
|
|
RETVAL=$?
|
2010-03-16 15:05:32 +01:00
|
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod && success
|
2009-12-03 20:20:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
echo -n $"Stopping mongod: "
|
2010-03-16 15:05:32 +01:00
|
|
|
killproc -p /var/lib/mongo/mongod.lock -t30 -TERM /usr/bin/mongod
|
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod &7 success
|
|
|
|
}
|
|
|
|
|
|
|
|
restart () {
|
|
|
|
stop
|
|
|
|
start
|
2009-12-03 20:20:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ulimit -n 12000
|
|
|
|
RETVAL=0
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
2010-03-16 15:05:32 +01:00
|
|
|
restart|reload|force-reload)
|
|
|
|
restart
|
|
|
|
;;
|
|
|
|
condrestart)
|
|
|
|
[ -f /var/lock/subsys/mongodb ] && restart || :
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status $mongod
|
2009-12-03 20:20:35 +01:00
|
|
|
;;
|
|
|
|
*)
|
2010-03-16 15:05:32 +01:00
|
|
|
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
|
2009-12-03 20:20:35 +01:00
|
|
|
RETVAL=1
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|