7 # description: mongod is a NoSQL database daemon.
10 # pidfile: /var/run/mongod.pid
14 # Required-Start: $syslog $local_fs $network
15 # Required-Stop: $syslog $local_fs $network
16 # Should-Start: $remote_fs
17 # Should-Stop: $remote_fs
18 # Default-Start: 3 4 5
19 # Default-Stop: 0 1 2 6
20 # Short-Description: MongoDB server
21 # Description: Starts and stops the MongoDB daemon
24 # Source function library
25 . /etc/rc.d/init.d/functions
28 . /etc/sysconfig/network
30 # Check that networking is up.
31 if is_yes "${NETWORKING}"; then
32 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
33 msg_network_down "mongod"
40 MONGOD_BIN="/usr/bin/mongod"
41 MONGOD_PIDFILE="/var/run/mongod.pid"
42 MONGOD_CONFIG="/etc/sysconfig/mongod"
48 [ -f /etc/sysconfig/mongod ] && . /etc/sysconfig/mongod
51 # Check if the service is already running?
52 if [ -f /var/lock/subsys/mongod ]; then
53 msg_already_running "mongod"
58 for config in /etc/mongod/*.conf ; do
59 instance=$(basename "$config" .conf)
60 msg_starting "mongod '$instance' instance"
61 if [ "$instance" = "default" ] ; then
62 pidfile="$MONGOD_PIDFILE"
64 pidfile="${MONGOD_PIDFILE%.pid}-$instance.log"
66 daemon --pidfile "$pidfile" --user $MONGOD_USER \
67 $MONGOD_BIN --config "$config" --fork
68 [ $? -eq 0 ] && started=$(($started + 1))
70 # at least one started - the service is running
71 [ $started -eq 0 ] && RETVAL=1
72 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
76 if [ ! -f /var/lock/subsys/mongod ]; then
77 msg_not_running "mongod"
81 for config in /etc/mongod/*.conf ; do
82 instance=$(basename "$config" .conf)
83 msg_stopping "mongod '$instance' instance"
84 if [ "$instance" = "default" ] ; then
85 pidfile="$MONGOD_PIDFILE"
87 pidfile="${MONGOD_PIDFILE%.pid}-$instance.log"
89 killproc --pidfile "$pidfile" mongod
91 rm -f /var/lock/subsys/mongod >/dev/null 2>&1
95 if [ ! -f /var/lock/subsys/mongod ]; then
96 msg_not_running "mongod"
106 if [ ! -f /var/lock/subsys/mongod ]; then
107 msg_not_running "mongod"
112 for config in /etc/mongod/*.conf ; do
113 instance=$(basename "$config" .conf)
114 msg_reloading "mongod '$instance' instance"
115 if [ "$instance" = "default" ] ; then
116 pidfile="$MONGOD_PIDFILE"
118 pidfile="${MONGOD_PIDFILE%.pid}-$instance.log"
120 killproc --pidfile "$pidfile" mongod -HUP
125 # See how we were called.
148 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"