Skip to content

Instantly share code, notes, and snippets.

@wbzyl
Created September 15, 2011 18:53
Show Gist options
  • Save wbzyl/1220116 to your computer and use it in GitHub Desktop.
Save wbzyl/1220116 to your computer and use it in GitHub Desktop.
MongoDB init.d script for Linux / Fedora 15
chkconfig —add mongodb
chkconfig mongodb on
#!/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
OPTIONS=" -f /home/wbzyl/.nosql/etc/mongodb/mongod.conf"
SYSCONFIG="/home/wbzyl/.nosql/etc/sysconfig/mongod"
mongod=${MONGOD-/home/wbzyl/.nosql/bin/mongod}
MONGO_USER=wbzyl
MONGO_GROUP=wbzyl
. "$SYSCONFIG" || true
start()
{
echo -n $"Starting mongod: "
daemon --user "$MONGO_USER" $mongod $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /home/wbzyl/.data/var/lock/subsys/mongod
}
stop()
{
echo -n $"Stopping mongod: "
killproc -p /home/wbzyl/.data/var/lib/mongo/mongod.lock -t30 -TERM /usr/bin/mongod
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /home/wbzyl/.data/var/lock/subsys/mongod
}
restart () {
stop
start
}
ulimit -n 12000
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f /home/wbzyl/.data/var/lock/subsys/mongod ] && restart || :
;;
status)
status $mongod
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
RETVAL=1
esac
exit $RETVAL
/home/wbzyl/.data/var/log/mongodb/*.log {
daily
rotate 8
copytruncate
delaycompress
compress
notifempty
missingok
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment