I have installed CouchDB 2.0 on Ubuntu 16.04, and can run it fine by launching ~couchdb/bin/couchdb.
Now I would like to make it start and stop properly on system boot/shutdown.
The doc states that daemonization scripts are no longer provided in 2.0, and I would like to avoid using runit
.
I have tried to use start-stop-daemon
, writing a shell-script (provided below if helpful). This way I can start
CouchDB, but the stop
does not work because no process have the name "couchdb" (everything is delegated to ERLang).
Moreover, when I update-rc.d couchdb.sh defaults
I get an error insserv: warning: script 'couchdb.sh' missing LSB tags and overrides
.
So how would you recommend to make a clean start/stop procedure? Many thanks!
#!/bin/sh -e
DAEMON="/home/couchdb/bin/couchdb"
daemon_OPT=""
DAEMONUSER="couchdb"
daemon_NAME="couchdb"
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
d_start () {
log_daemon_msg "Starting system $daemon_NAME Daemon"
start-stop-daemon --background --name $daemon_NAME --start --quiet --chuid $DAEMONUSER --exec $DAEMON -- $daemon_OPT
log_end_msg $?
}
d_stop () {
log_daemon_msg "Stopping system $daemon_NAME Daemon"
start-stop-daemon --name $daemon_NAME --stop --retry 5 --quiet
log_end_msg $?
}
case "$1" in
start|stop)
d_${1}
;;
restart|reload|force-reload)
d_stop
d_start
;;
force-stop)
d_stop
killall -q $daemon_NAME || true
sleep 2
killall -q -9 $daemon_NAME || true
;;
status)
status_of_proc "$daemon_NAME" "$DAEMON" "system-wide $daemon_NAME" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$daemon_NAME {start|stop|force-stop|restart|reload|force-reload|status}"
exit 1
;;
esac
exit 0
From here: https://www.jamescoyle.net/how-to/2527-add-systemd-startup-script-for-couchdb