Skip to content

Instantly share code, notes, and snippets.

@georgefs
Created December 10, 2013 14:49
Show Gist options
  • Save georgefs/7891795 to your computer and use it in GitHub Desktop.
Save georgefs/7891795 to your computer and use it in GitHub Desktop.
init.d
#!/bin/bash
PID_FILE=/var/run/mongo.pid
MONGOD=/opt/mongodb-linux-x86_64-2.0.6/bin/mongod
###
# main point
###
case "$1" in
start)
$MONGOD --dbpath data/db --logpath /var/log/mongodb/log.txt --fork --auth --pidfilepath $PID_FILE
;;
stop)
kill -9 `cat $PID_FILE`
;;
restart|force-reload)
echo "Restarting : "
kill -9 `cat $PID_FILE`
sleep 1
$MONGOD --dbpath data/db --logpath /var/log/mongodb/log.txt --fork --auth --pidfilepath $PID_FILE
;;
*)
echo "Usage: $NAME {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment