Forked from yongjhih/couchbase-sync-gateway_init.d
Last active
August 29, 2015 14:07
-
-
Save mrjohannchang/8f0a5e25c5c249dad3b7 to your computer and use it in GitHub Desktop.
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 sync_gateway | |
# | |
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_PATH=/opt/couchbase-sync-gateway/bin/ | |
DAEMON="${DAEMON_PATH}sync_gateway" | |
#DAEMON="/home/andrew/workspace/sync-gateway/sync-gateway" | |
DAEMONOPTS=/opt/couchbase-sync-gateway/etc/sync-gateway.json | |
LOGFILE=/opt/couchbase-sync-gateway/var/lib/couchbase/logs/start.log | |
PIDFILE=/opt/couchbase-sync-gateway/var/lib/couchbase/couchbase-sync-gateway.pid | |
NAME=couchbase | |
USER=couchbase | |
DESC="Couchbase sync_gateway" | |
# /etc/security/limits.d/couchbase.conf | |
# couchbase-sync-gateway soft nofile 32769 | |
# couchbase-sync-gateway hard nofile 32769 | |
# couchbase-sync-gateway soft memlock 1048576 | |
# couchbase-sync-gateway hard memlock 2097152 | |
ulimit -n 32768 | |
ulimit -m 2097152 | |
case "$1" in | |
start) | |
printf "%-50s" "Starting $NAME..." | |
cd $DAEMON_PATH | |
if [ ! -d `dirname $DAEMONOPTS` ]; then mkdir -p `dirname $DAEMONOPTS` && touch $DAEMONOPTS; fi | |
if [ ! -d `dirname $LOGFILE` ]; then mkdir -p `dirname $LOGFILE`; fi | |
if [ ! -d `dirname $PIDFILE` ]; then mkdir -p `dirname $PIDFILE`; fi | |
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --chuid $USER --exec $DAEMON -- $DAEMONOPTS > $LOGFILE 2>&1 & | |
echo | |
;; | |
status) | |
printf "%-50s" "Checking $NAME..." | |
if [ -f $PIDFILE ]; then | |
PID=`cat $PIDFILE` | |
if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then | |
printf "%s\n" "Process dead but pidfile exists" | |
else | |
echo "Running" | |
fi | |
else | |
printf "%s\n" "Service not running" | |
fi | |
;; | |
stop) | |
printf "%-50s" "Stopping $NAME" | |
PID=`cat $PIDFILE` | |
cd $DAEMON_PATH | |
if [ -f $PIDFILE ]; then | |
kill -HUP $PID | |
printf "%s\n" "Ok" | |
rm -f $PIDFILE | |
else | |
printf "%s\n" "pidfile not found" | |
fi | |
;; | |
restart) | |
$0 stop | |
$0 start | |
;; | |
*) | |
echo "Usage: $0 {status|start|stop|restart}" | |
exit 1 | |
esac |
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
{ | |
"interface":"0.0.0.0:4984", | |
"adminInterface":"0.0.0.0:4985", | |
"log":["REST"], | |
"databases":{ | |
"octory":{ | |
"server":"http://localhost:8091", | |
"bucket":"default", | |
"sync":`function(doc) { | |
access(doc.members, doc.channels); | |
channel(doc.channels); | |
}`, | |
"users": { | |
"GUEST": {"disabled": true, "admin_channels": ["*"]} | |
} | |
} | |
}, | |
"facebook" : { | |
"register" : true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment