Skip to content

Instantly share code, notes, and snippets.

@neutrino
Forked from nl/sync-gateway.conf
Created January 29, 2014 15:56
Show Gist options
  • Save neutrino/8690944 to your computer and use it in GitHub Desktop.
Save neutrino/8690944 to your computer and use it in GitHub Desktop.
description "Sync Gateway Upstart Script”
version "0.1.0"
author "Nicolas Lapomarda"
# Upstart has nothing in $PATH by default
env RUNAS=db
env HOME=/home/$RUNAS
env PATH=$HOME/sync_gateway/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
env PATH_TO_GATEWAY=$HOME/sync_gateway/bin/sync_gateway
env PATH_TO_JSON=$HOME/sync_gateway.json
env LOGSDIR=$HOME/logs
env PIDFILE=/var/run/sync-gateway.pid
# 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