Created
July 9, 2015 01:16
-
-
Save cornfeedhobo/231a74a6f5e150a7e57c to your computer and use it in GitHub Desktop.
/etc/init.d/couchbase-server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 40960 | |
ulimit -c unlimited | |
ulimit -l unlimited | |
daemon --pidfile=${PIDFILE} --user couchbase "$DAEMON -- -noinput -detached > /opt/couchbase/var/lib/couchbase/logs/start.log 2>&1" | |
errcode=$? | |
return $errcode | |
} | |
stop() { | |
daemon ${DAEMON} -k | |
errcode=$? | |
[ $errcode = 0 ] && rm -f ${PIDFILE} | |
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