Skip to content

Instantly share code, notes, and snippets.

@ihor
Last active January 19, 2018 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihor/3829563 to your computer and use it in GitHub Desktop.
Save ihor/3829563 to your computer and use it in GitHub Desktop.
/etc/init.d/mongodb script for Homebrew installed MongoDB
#!/bin/bash
DAEMON=/usr/local/bin/mongod
OPTS='run --config /usr/local/etc/mongo/mongod.conf'
NAME=mongodb
DESC=mongodb
test -x $DAEMON || exit 0
set -e
start()
{
$DAEMON $OPTS > /var/log/mongodb/mongo.log 2>&1 &
return
}
stop()
{
kill -15 `cat /usr/local/var/mongodb/mongod.lock`
return
}
case "$1" in
start)
echo -n "Starting $DESC: "
start
echo "started."
;;
stop)
echo -n "Stopping $DESC: "
stop
echo "stopped."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
stop
sleep 1
start
echo "restarted."
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment