Created
May 3, 2011 16:03
-
-
Save srounet/953618 to your computer and use it in GitHub Desktop.
init.d script for mongo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
DAEMON=/usr/bin/mongod | |
MONGOPID=`ps -ef | grep 'mongod' | grep -v grep | awk '{print $2}'` | |
CONFIGFILE=/etc/mongodb.conf | |
RUNAS=mongodb | |
test -x $PROGRAM || exit 0 | |
case "$1" in | |
start) | |
log_begin_msg "Starting MongoDB server" | |
exec start-stop-daemon --start --chuid $RUNAS --exec $DAEMON -- --config $CONFIGFILE | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment