# Upstart script for MongoDB. This is NOT the mongo config file.
# For information on the how to maintain this script:
# http://upstart.ubuntu.com/cookbook/
# http://upstart.ubuntu.com/wiki/Stanzas

respawn
limit nofile 20000 20000

kill timeout 300 # wait 300s between SIGTERM and SIGKILL.

start on runlevel [2345]
stop on runlevel [06]

exec runuser --shell=/bin/bash -c "/opt/mongo/bin/mongod -f /mongo/mongod.conf" mongo

post-start script
# Try to connect to mongo. We might need to put this in a loop and repeat until successful. 
/opt/mongo/bin/mongo </dev/null 
end script
