Skip to content

Instantly share code, notes, and snippets.

@craigminihan
Created August 16, 2013 15:53
Show Gist options
  • Save craigminihan/6251087 to your computer and use it in GitHub Desktop.
Save craigminihan/6251087 to your computer and use it in GitHub Desktop.
This is a VERY simple script to run couchdb-lucene as a daemon on CentOS 6.x. * Download and rename as couchdb-lucene and place in: /etc/rc.d/init.d * Make it executable: chmod 755 /etc/rc.d/init.d/couchdb-lucene * Add it as a daemon: chkconfig --add couchdb-lucene * Start it: service couchdb-lucene start
#!/bin/sh
#
# This is a VERY simple script to run couchdb-lucene as a daemon on CentOS 6.x
# It is assumed that Java is installed and that couchdb-lucene is present on /usr/local
#
### BEGIN INIT INFO
# Provides: couchdb-lucene
# Short-Description: Starts couchdb-lucene as a daemon
# Description: Starts couchdb-lucene as a daemon
### END INIT INFO
# chkconfig: 235 98 98
# load the init functions we need
. /etc/init.d/functions
VERSION=0.9.0
DAEMON=/usr/local/couchdb-lucene-$VERSION/bin/run
LOCKFILE=/var/lock/subsys/couchdb-lucene
# if the 'run' script file sees a PIDFILE variable then it will run like a daemon, so we need to export this var
export PIDFILE=/var/run/couchdb-lucene.pid
start() {
daemon --pidfile $PIDFILE $DAEMON
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
echo
return $RETVAL
}
stop() {
killproc -p $PIDFILE $DAEMON
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE && rm -f $PIDFILE
echo
return $RETVAL
}
restart() {
stop
start
}
RETVAL=0
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p $PIDFILE couchdb-lucene
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload}"
exit 2
esac
exit $?
@GMishx
Copy link

GMishx commented Aug 2, 2018

Same script for Debian based systems:

!/bin/sh
#
### BEGIN INIT INFO
# Provides: couchdb-lucene
# Short-Description: Starts couchdb-lucene as a daemon
# Description: Starts couchdb-lucene as a daemon
### END INIT INFO

# load the init functions we need
. /lib/lsb/init-functions

set -e

VERSION=0.9.0
DAEMON=/opt/couchdb-lucene-${VERSION}/bin/run
DESC="Couchdb-Lucene"
LOCKFILE=/var/lock/subsys/couchdb-lucene

# if the 'run' script file sees a PIDFILE variable then it will run like a daemon, so we need to export this var
export PIDFILE=/var/run/couchdb-lucene.pid

start() {
        start-stop-daemon --oknodo --start -m -p $PIDFILE --exec $DAEMON
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch $LOCKFILE
        echo
        return $RETVAL
}

stop() {
        start-stop-daemon --oknodo --stop -p $PIDFILE
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f $LOCKFILE && rm -f $PIDFILE
        echo
        return $RETVAL
}

restart() {
        stop
        start
}

RETVAL=0

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        start-stop-daemon --status -p $PIDFILE couchdb-lucene
        ;;
  restart|reload)
        restart
        ;;
  *)
        echo "Usage: $0 {start|stop|status|restart|reload}"
        exit 2
esac

exit $?

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