Skip to content

Instantly share code, notes, and snippets.

@tfitch
Created August 12, 2014 19:04
Show Gist options
  • Save tfitch/1a48dc7d3f5e36dea015 to your computer and use it in GitHub Desktop.
Save tfitch/1a48dc7d3f5e36dea015 to your computer and use it in GitHub Desktop.
mongodb init.d
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
# config: /apps/mongodb/conf/awc-mongodb.conf
# pidfile: /apps/mongodb/mongo.pid
. /etc/rc.d/init.d/functions
SYSCONFIG="/apps/mongodb/conf/awc-mongodb.sysconfig"
MONGO_USER=cayenbld
SUBSYS_LOCK_FILE=/var/lock/subsys/mongod
. "$SYSCONFIG" || true
start()
{
echo -n $"Starting mongod: "
daemon --user "$MONGO_USER" --pidfile "$DBPATH"/mongod.lock $DAEMON $DAEMON_OPTS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $SUBSYS_LOCK_FILE
}
stop()
{
echo -n $"Stopping mongod: "
killproc -p "$DBPATH"/mongod.lock -d 300 $DAEMON
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $SUBSYS_LOCK_FILE
}
restart () {
stop
start
}
ulimit -f unlimited
ulimit -t unlimited
ulimit -v unlimited
ulimit -n 64000
ulimit -m unlimited
ulimit -u 32000
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f $SUBSYS_LOCK_FILE ] && restart || :
;;
status)
status -p "$DBPATH"/mongod.lock $DAEMON
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
RETVAL=1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment