Skip to content

Instantly share code, notes, and snippets.

@infynyxx
Created August 16, 2010 18:30
Show Gist options
  • Save infynyxx/527484 to your computer and use it in GitHub Desktop.
Save infynyxx/527484 to your computer and use it in GitHub Desktop.
init.d script for MongoDB
MONGO_OPTS="--quiet --pairwith 192.168.1.6 --arbiter 192.168.1.5"
#! /bin/sh
if [ -s /etc/default/mongodb ]; then
. /etc/default/mongodb
else
log_failure_msg "Could not find /etc/default/mongodb (aborting)"
exit 1
fi
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/mongodb/bin/mongod
PIDFILE=/data/db/mongod.lock
LOGFILE=/opt/mongodb/logs/mongod.log
NAME=mongodb
DESC=mongodb
test -x $DAEMON || exit 0
case "$1" in
start)
echo -n "Starting $DESC: "
#start-stop-daemon --make-pidfile --pidfile $PIDFILE --exec $DAEMON --start -- run >> $LOGFILE&
$DAEMON $MONGO_OPTS >> $LOGFILE&
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
#start-stop-daemon --quiet --pidfile $PIFDILE --exec $DAEMON --stop
#start-stop-daemon --quiet --pidfile /opt/mongodb/logs/mongodb.pid --exec /opt/mongodb/bin/mongod --stop
kill -1 `cat $PIDFILE`
rm $PIDFILE
echo "$NAME."
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment