Skip to content

Instantly share code, notes, and snippets.

@sletix
Created July 1, 2012 14:03
Show Gist options
  • Select an option

  • Save sletix/3028523 to your computer and use it in GitHub Desktop.

Select an option

Save sletix/3028523 to your computer and use it in GitHub Desktop.
`/etc/default/thinking_sphinx.conf` and `/etc/init.d/thinking_sphinx`
#!/bin/bash -e
### BEGIN INIT INFO
# Provides: thinking_sphinx
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop Sphinx daemon for Thinking Sphinx
### END INIT INFO
CONFIG_FILE=/etc/default/thinking_sphinx.conf
. $CONFIG_FILE || exit
if [[ `whoami` != 'root' ]]
then echo "Only root can use $PROGRAM_NAME tasks"; exit 1
fi
case "$1" in
start)
echo "Starting $PROGRAM_NAME"
cd $APP_PATH
sudo -u $USER RAILS_ENV=$RAILS_ENV bundle exec rake thinking_sphinx:start
echo
;;
stop)
echo "Stopping $PROGRAM_NAME"
cd $APP_PATH
sudo -u $USER RAILS_ENV=$RAILS_ENV bundle exec rake thinking_sphinx:stop
echo
;;
rebuild)
echo "re-Building (Stop/Index/Start) $PROGRAM_NAME"
cd $APP_PATH
sudo -u $USER RAILS_ENV=$RAILS_ENV bundle exec rake thinking_sphinx:rebuild
echo
;;
restart)
echo "re-Starting $PROGRAM_NAME"
cd $APP_PATH
sudo -u $USER RAILS_ENV=$RAILS_ENV bundle exec rake thinking_sphinx:restart
echo
;;
delayed_delta)
echo "Process stored delta index requests"
cd $APP_PATH
sudo -u $USER RAILS_ENV=$RAILS_ENV bundle exec rake thinking_sphinx:delayed_delta
echo
;;
*)
echo "Usage: $0 {start|stop|restart|rebuild|delayed_delta}"
exit 1
esac
USER='app'
APP_PATH='/home/app/current'
RAILS_ENV='production'
PROGRAM_NAME='Thinking Sphinx'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment