Created
July 31, 2009 10:03
-
-
Save ancorcruz/159164 to your computer and use it in GitHub Desktop.
Thinking Sphinx init.d script
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/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 rake thinking_sphinx:start | |
echo | |
;; | |
stop) | |
echo "Stopping $PROGRAM_NAME" | |
cd $APP_PATH | |
sudo -u $USER RAILS_ENV=$RAILS_ENV rake thinking_sphinx:stop | |
echo | |
;; | |
rebuild) | |
echo "re-Building (Stop/Index/Start) $PROGRAM_NAME" | |
cd $APP_PATH | |
sudo -u $USER RAILS_ENV=$RAILS_ENV rake thinking_sphinx:rebuild | |
echo | |
;; | |
restart) | |
echo "re-Starting $PROGRAM_NAME" | |
cd $APP_PATH | |
sudo -u $USER RAILS_ENV=$RAILS_ENV rake thinking_sphinx:restart | |
echo | |
;; | |
delayed_delta) | |
echo "Process stored delta index requests" | |
cd $APP_PATH | |
sudo -u $USER RAILS_ENV=$RAILS_ENV rake thinking_sphinx:delayed_delta | |
echo | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|rebuild|delayed_delta}" | |
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
USER='user' | |
APP_PATH='/path/to/your/rails/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