# /etc/init/couchdb-lucene.conf description "CouchDB-Lucene server" script cd /PATH/TO/couchdb_lucene exec sudo -u couchdb ./bin/run end script post-start script # hack to create a pid file CDB_PID=`status couchdb-lucene |egrep -oi '([0-9]+)$' |head -n1` echo $CDB_PID >/var/run/couchdb-lucene.pid end script # monit check process couchdb_lucene with pidfile /var/run/couchdb-lucene.pid group database start program = start couchdb-lucene stop program = stop couchdb-lucene if failed host 127.0.0.1 port 5985 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 depends on couchdb