Archive

Archive for the ‘mongo’ Category

Ubuntu start up script for Mongo DB Server

October 25, 2010 5 comments

Very basic start up script for Mongo DB Server.
copy the file to /etc/init.d, set the execution flag, and run update-rc.d script_name defaults

#!/bin/sh

### BEGIN INIT INFO
# Provides:     mongodb
# Required-Sart:
# Required-Stop:
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description: mongodb
# Description: mongo db server
### END INIT INFO

. /lib/lsb/init-functions

PROGRAM=/usr/bin/mongod
MONGOPID=`ps -ef | grep 'mongod' | grep -v grep | awk '{print $2}'`

test -x $PROGRAM || exit 0

case "$1" in
  start)
     log_begin_msg "Starting MongoDB server"
     /usr/bin/mongod --fork --quiet --dbpath /data/db --logpath /var/log/mongodb.log
     log_end_msg 0
     ;;
  stop)
     log_begin_msg "Stopping MongoDB server"		
     if [ ! -z "$MONGOPID" ]; then 		
	kill -15 $MONGOPID
     fi
     log_end_msg 0
     ;;  
  status)
     ;;
  *)
     log_success_msg "Usage: /etc/init.d/mongodb {start|stop|status}"
     exit 1
esac

exit 0
Categories: linux, mongo
Follow

Get every new post delivered to your Inbox.