I can't figure out how to auto-restart mongodb on Ubuntu 16.04 in the event that it crashes due to memory-pressure.
I'm using supervisord for other scripts etc, but mongod is through systemctl and I'm not sure how that ties into it.
You can either put the command in your /etc/bashrc script under and if condition i.e. if the mongod process is not already running, then start it. Other way is to modify your /etc/rc. local and add the command to start mongod in that file. It will start at bootup.
Figured it out:
sudo vim /lib/systemd/system/mongod.service
Restart=always
under service
sudo systemctl daemon-reload
Now whenever mongod gets killed. It'll get respawned by systemctl.
When you install mongoDB
just run systemctl enable mongod.service
on terminal.
This will make your mongoDB service auto-start on every restart.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With