1# Ubuntu upstart file at /etc/init/mongod.conf 2 3# Recommended ulimit values for mongod or mongos 4# See http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings 5# 6limit fsize unlimited unlimited 7limit cpu unlimited unlimited 8limit as unlimited unlimited 9limit nofile 64000 64000 10limit rss unlimited unlimited 11limit nproc 64000 64000 12limit memlock unlimited unlimited 13 14kill timeout 300 # wait 300s between SIGTERM and SIGKILL. 15 16pre-start script 17 DAEMONUSER=${DAEMONUSER:-mongodb} 18 if [ ! -d /var/lib/mongodb ]; then 19 mkdir -p /var/lib/mongodb && chown mongodb:mongodb /var/lib/mongodb 20 fi 21 if [ ! -d /var/log/mongodb ]; then 22 mkdir -p /var/log/mongodb && chown mongodb:mongodb /var/log/mongodb 23 fi 24 touch /var/run/mongodb.pid 25 chown $DAEMONUSER /var/run/mongodb.pid 26end script 27 28start on runlevel [2345] 29stop on runlevel [06] 30 31script 32 ENABLE_MONGOD="yes" 33 CONF=/etc/mongod.conf 34 DAEMON=/usr/bin/mongod 35 DAEMONUSER=${DAEMONUSER:-mongodb} 36 DAEMONGROUP=${DAEMONGROUP:-mongodb} 37 38 if [ -f /etc/default/mongod ]; then . /etc/default/mongod; fi 39 40 # Handle NUMA access to CPUs (SERVER-3574) 41 # This verifies the existence of numactl as well as testing that the command works 42 NUMACTL_ARGS="--interleave=all" 43 if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null 44 then 45 NUMACTL="$(which numactl) -- $NUMACTL_ARGS" 46 DAEMON_OPTS=${DAEMON_OPTS:-"--config $CONF"} 47 else 48 NUMACTL="" 49 DAEMON_OPTS="-- "${DAEMON_OPTS:-"--config $CONF"} 50 fi 51 52 if [ "x$ENABLE_MONGOD" = "xyes" ] 53 then 54 exec start-stop-daemon --start \ 55 --chuid $DAEMONUSER:$DAEMONGROUP \ 56 --pidfile /var/run/mongodb.pid \ 57 --make-pidfile \ 58 --exec $NUMACTL $DAEMON $DAEMON_OPTS 59 fi 60end script 61