Skip to content

Instantly share code, notes, and snippets.

@nl
Created January 21, 2014 15:20
Show Gist options
  • Save nl/8542021 to your computer and use it in GitHub Desktop.
Save nl/8542021 to your computer and use it in GitHub Desktop.
Sync Gateway Upstart Script This should be placed in /etc/init/sync-gateway.conf. You should set: - RUNAS to the username the gateway should be run as, - PATH_TO_GATEWAY to the path to the gateway binary (output of ./build.sh if you build from source), - PATH_TO_JSON to the path of the config JSON file, - LOGSDIR to the path of the logs director…
description "Sync Gateway"
version "0.1.0"
author "Nicolas Lapomarda"
# Upstart has nothing in $PATH by default
env PATH=/home/db/sync_gateway/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
env PATH_TO_GATEWAY=/home/db/sync_gateway/bin/sync_gateway
env PATH_TO_JSON=/home/db/sync_gateway.json
env LOGSDIR=/home/db/logs
env PIDFILE=/var/run/sync-gateway.pid
env RUNAS=db
# Keep the server running on crash or machine reboot
start on started mountall
stop on shutdown
respawn
pre-start script
mkdir -p $LOGS
chown -R $RUNAS:$RUNAS $LOGS
end script
# Start the Sync Gateway and redirect output streams to log files
script
# Keep a pid around
echo $$ > $PIDFILE
exec su -c “$PATH_TO_GATEWAY $PATH_TO_JSON >> $LOGS/sync_access.log 2>> $LOGS/sync_error.log" $RUNAS
end script
# Remove pid file when we stop the server
pre-stop script
rm $PIDFILE
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment