Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ubuntu upstart script for MongoDB with automatic repair
# Ubuntu upstart file at /etc/init/mongodb.conf
pre-start script
mkdir -p /var/lib/mongodb/
mkdir -p /var/log/mongodb/
end script
start on runlevel [2345]
stop on runlevel [06]
script
ENABLE_MONGODB="yes"
if [ -f /etc/default/mongodb ]; then . /etc/default/mongodb; fi
if [ "x$ENABLE_MONGODB" = "xyes" ]; then
if [ -f /var/lib/mongodb/mongod.lock ]; then
rm /var/lib/mongodb/mongod.lock
sudo -u mongodb /usr/bin/mongod --config /etc/mongodb.conf --repair
fi
exec start-stop-daemon --start --quiet --chuid mongodb --exec /usr/bin/mongod -- --config /etc/mongodb.conf
fi
end script
@shingara

This comment has been minimized.

Copy link

@shingara shingara commented May 5, 2014

thanks. It's useful

@simon-p-r

This comment has been minimized.

Copy link

@simon-p-r simon-p-r commented May 16, 2014

Thanks very helpful

@Israphel

This comment has been minimized.

Copy link

@Israphel Israphel commented Jan 8, 2016

Thanks!

@slavikdev

This comment has been minimized.

Copy link

@slavikdev slavikdev commented Oct 30, 2016

Thank you!
In my case after official installation instructions for Ubuntu config file was named /etc/mongod.conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment