I have decided to use the latest development version of CouchDB (1.3.0a-272d641-git) on my machine. I am using CouchDB in a shop system to store user like contact requests. Nothing dramatical important.
Since a lot of different software is running on this machine which is important for that shop and it’s availability is essential (like elasticsearch), I decided to use Monit for monitoring and alerting.
Unfortunately I could not get it working with CouchDB. And - surprise, surprise - CouchDB stopped working from time to time (btw - especially version 1.3.0a-72ea7e3-git). I had many approaches and I am aware that a correctly configured Erlang installation should fix the problem, because “heart” is taking the monitoring job for CouchDB. But - it still crashed.
So now I am glad that I got it fixed and finally, it’s dead simple. Her is the (or better my, for me working) solution:
check process couchdb with pidfile /usr/local/var/run/couchdb/couchdb.pid group database start program = "/etc/init.d/couchdb start -u couchdb" stop program = "/etc/init.d/couchdb stop -u couchdb" if failed host 127.0.0.1 port 5984 then restart if cpu is greater than 40% for 2 cycles then alert if cpu > 60% for 5 cycles then restart if 10 restarts within 10 cycles then timeout
This is the content of the file /etc/monit/conf.d/couchdb.conf and the most important parts are:
- correct path to couchdb.pid
- start stop CouchDB as user couchdb (-u couchdb)
So if you have trouble with this and just found old or not for you working examples in the w3, check this one ;-)