mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-28 07:59:02 +01:00
5d4b3fe40c
The default upstart config installed with MongoDB doesn't provide the `--pidfile` or `--make-pidfile` options to `start-stop-daemon`, which means it determines whether or not MongoDB is running by inspecting the process table to see if there are any instances of "mongod" running. This is a pretty crude mechanism, and we can make it substantially more reliable (not susceptible to mongod instances running inside LXC containers or similar) by simply getting start-stop-daemon to write a pidfile.
59 lines
1.6 KiB
Plaintext
59 lines
1.6 KiB
Plaintext
# Ubuntu upstart file at /etc/init/mongod.conf
|
|
|
|
# Recommended ulimit values for mongod or mongos
|
|
# See http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
|
|
#
|
|
limit fsize unlimited unlimited
|
|
limit cpu unlimited unlimited
|
|
limit as unlimited unlimited
|
|
limit nofile 64000 64000
|
|
limit rss unlimited unlimited
|
|
limit nproc 32000 32000
|
|
|
|
kill timeout 300 # wait 300s between SIGTERM and SIGKILL.
|
|
|
|
pre-start script
|
|
DAEMONUSER=${DAEMONUSER:-mongodb}
|
|
if [ ! -d /var/lib/mongod ]; then
|
|
mkdir -p /var/lib/mongodb && chown mongodb:mongodb /var/lib/mongodb
|
|
fi
|
|
if [ ! -d /var/log/mongod ]; then
|
|
mkdir -p /var/log/mongodb && chown mongodb:mongodb /var/log/mongodb
|
|
fi
|
|
touch /var/run/mongodb.pid
|
|
chown $DAEMONUSER /var/run/mongodb.pid
|
|
end script
|
|
|
|
start on runlevel [2345]
|
|
stop on runlevel [06]
|
|
|
|
script
|
|
ENABLE_MONGOD="yes"
|
|
CONF=/etc/mongod.conf
|
|
DAEMON=/usr/bin/mongod
|
|
DAEMONUSER=${DAEMONUSER:-mongodb}
|
|
|
|
if [ -f /etc/default/mongod ]; then . /etc/default/mongod; fi
|
|
|
|
# Handle NUMA access to CPUs (SERVER-3574)
|
|
# This verifies the existence of numactl as well as testing that the command works
|
|
NUMACTL_ARGS="--interleave=all"
|
|
if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null
|
|
then
|
|
NUMACTL="$(which numactl) -- $NUMACTL_ARGS"
|
|
DAEMON_OPTS=${DAEMON_OPTS:-"--config $CONF"}
|
|
else
|
|
NUMACTL=""
|
|
DAEMON_OPTS="-- "${DAEMON_OPTS:-"--config $CONF"}
|
|
fi
|
|
|
|
if [ "x$ENABLE_MONGOD" = "xyes" ]
|
|
then
|
|
exec start-stop-daemon --start \
|
|
--chuid $DAEMONUSER \
|
|
--pidfile /var/run/mongodb.pid \
|
|
--make-pidfile \
|
|
--exec $NUMACTL $DAEMON $DAEMON_OPTS
|
|
fi
|
|
end script
|