Skip to content

Instantly share code, notes, and snippets.

@stuzart
Forked from anonymous/gist:2788607
Last active April 22, 2017 12:24
Show Gist options
  • Save stuzart/3143434 to your computer and use it in GitHub Desktop.
Save stuzart/3143434 to your computer and use it in GitHub Desktop.
init.d script for stopping and starting sunspot solr
#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
APP_PATH="/srv/rails/seek"
start_sunspot(){
echo "Starting Sunspot"
sudo -iu www-data bash -c "source ~/.rvm/scripts/rvm && cd $APP_PATH && bundle exec rake sunspot:solr:start RAILS_ENV=production"
}
stop_sunspot(){
echo "Stopping Sunspot"
sudo -iu www-data bash -c "source ~/.rvm/scripts/rvm && cd $APP_PATH && bundle exec rake sunspot:solr:stop RAILS_ENV=production"
}
COMMAND="$1"
shift
case $COMMAND in
status)
;;
start|stop|restart)
$ECHO
if [ "$COMMAND" = "stop" ]; then
stop_sunspot
elif [ "$COMMAND" = "start" ]; then
start_sunspot
elif [ "$COMMAND" = "restart" ]; then
stop_sunspot
sleep 1s
start_sunspot
exit 0
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment