Skip to content

Instantly share code, notes, and snippets.

@tleyden
Created December 3, 2014 21:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tleyden/b46eedf729006d71fd36 to your computer and use it in GitHub Desktop.
Save tleyden/b46eedf729006d71fd36 to your computer and use it in GitHub Desktop.
/etc/init.d/couchbase-server
# cat /etc/init.d/couchbase-server
#!/bin/sh
#
# Startup / shutdown script for the couchbase server
#
# Copyright (c) 2011, Couchbase, Inc.
# All rights reserved
#
#
### BEGIN INIT INFO
# Provides: couchbase-server
# Required-Start: $network $local_fs
# Required-Stop:
# Should-Start: $named
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: couchbase server
# Description: couchbase server
### END INIT INFO
. /etc/init.d/functions
if [ "$(id -u)" != "0" ]; then
echo "Must run as root"
exit 1
fi
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/couchbase/bin/couchbase-server
PIDFILE=/opt/couchbase/var/lib/couchbase/couchbase-server.pid
NODEFILE=/opt/couchbase/var/lib/couchbase/couchbase-server.node
COOKIEFILE=/opt/couchbase/var/lib/couchbase/couchbase-server.cookie
test -f $DAEMON || exit 0
# Otherwise, RHEL (and apparently Fedora) tries to "help" and set soft
# limit of core file size to 0 for daemons. It's done as part of
# daemon shell function shortly after changing user. See MB-6601
DAEMON_COREFILE_LIMIT=unlimited
start() {
touch $PIDFILE $NODEFILE $COOKIEFILE
chown couchbase $PIDFILE $NODEFILE $COOKIEFILE
cd /opt/couchbase/var/lib/couchbase
ulimit -n 10240
ulimit -c unlimited
ulimit -l unlimited
daemon --user couchbase "$DAEMON -- -noinput -detached > /opt/couchbase/var/lib/couchbase/logs/start.log 2>&1"
errcode=$?
return $errcode
}
stop() {
$DAEMON -k
errcode=$?
return $errcode
}
running() {
pidofproc -p $PIDFILE $DAEMON >/dev/null
errcode=$?
return $errcode
}
case $1 in
start)
if running ; then
warning && echo "couchbase-server is already started"
exit 0
fi
echo -n $"Starting couchbase-server"
start
echo
;;
stop)
echo -n $"Stopping couchbase-server"
stop
echo
;;
restart)
echo -n $"Stopping couchbase-server"
stop
echo
echo -n $"Starting couchbase-server"
start
echo
;;
status)
if running ; then
echo "couchbase-server is running"
exit 0
else
echo "couchbase-server is not running"
exit 3
fi
;;
*)
echo "Usage: /etc/init.d/couchbase-server {start|stop|restart|status}" >&2
exit 3
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment