#
# chkconfig: 345 60 40
#
-# description: mongod is a cache daemon.
+# description: mongod is a NoSQL database daemon.
#
# processname: mongod
# pidfile: /var/run/mongod.pid
# Get network config
. /etc/sysconfig/network
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+ if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+ msg_network_down "mongod"
+ exit 1
+ fi
+else
+ exit 0
+fi
+
MONGOD_BIN="/usr/bin/mongod"
-MONGOD_LOGFILE="/var/log/mongo/mongod.log"
MONGOD_PIDFILE="/var/run/mongod.pid"
MONGOD_CONFIG="/etc/sysconfig/mongod"
return
fi
- msg_starting "mongod"
- daemon --pidfile $MONGOD_PIDFILE --user $MONGOD_USER \
- $MONGOD_BIN --config /etc/mongod.conf run
- ret=$?
- [ $ret = 0 ] || RETVAL=$?
+ started=0
+ for config in /etc/mongod/*.conf ; do
+ instance=$(basename "$config" .conf)
+ msg_starting "mongod '$instance' instance"
+ if [ "$instance" = "default" ] ; then
+ pidfile="$MONGOD_PIDFILE"
+ else
+ pidfile="${MONGOD_PIDFILE%.pid}-$instance.log"
+ fi
+ daemon --pidfile "$pidfile" --user $MONGOD_USER \
+ $MONGOD_BIN --config "$config" --fork
+ [ $? -eq 0 ] && started=$(($started + 1))
+ done
+ # at least one started - the service is running
+ [ $started -eq 0 ] && RETVAL=1
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
}
return
fi
- msg_stopping "mongod"
- killproc --pidfile $MONGOD_PIDFILE mongod
+ for config in /etc/mongod/*.conf ; do
+ instance=$(basename "$config" .conf)
+ msg_stopping "mongod '$instance' instance"
+ if [ "$instance" = "default" ] ; then
+ pidfile="$MONGOD_PIDFILE"
+ else
+ pidfile="${MONGOD_PIDFILE%.pid}-$instance.log"
+ fi
+ killproc --pidfile "$pidfile" mongod
+ done
rm -f /var/lock/subsys/mongod >/dev/null 2>&1
}
return
fi
- msg_reloading "mongod"
- killproc --pidfile $MONGOD_PIDFILE mongod -HUP
+ for config in /etc/mongod/*.conf ; do
+ instance=$(basename "$config" .conf)
+ msg_reloading "mongod '$instance' instance"
+ if [ "$instance" = "default" ] ; then
+ pidfile="$MONGOD_PIDFILE"
+ else
+ pidfile="${MONGOD_PIDFILE%.pid}-$instance.log"
+ fi
+ killproc --pidfile "$pidfile" mongod -HUP
+ done
}
RETVAL=0