engineyard/ey-cloud-recipes — pull request #109 by grumpit (2013-06-04 03:22:11+00:00)
Title: update to support thinking_sphinx v3

One additional change would be that there would need to be a ts_searchd file in /engineyard/bin/searchd something like this:

```
#!/bin/sh
# This script starts and stops the searchd
# This script belongs in /engineyard/bin/searchd
###############################################################################
export PATH=/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.2
###############################################################################

usage() {
echo "Usage: $0 {start, stop, configure, reindex} [environment]"
exit 1
}

if [ $# -lt 2 ]; then usage; fi

if [ -z "$3" ]; then
FRAMEWORK_ENV=production
else
FRAMEWORK_ENV="$3"
fi

###############################################################################
LOGBASE=/var/log/engineyard/sphinx/$1
PIDFILE=/var/run/sphinx/$1.pid
CONFIGFILE=/data/$1/shared/config/sphinx.yml
GEMFILE=/data/$1/current/Gemfile
OUTPUT=$LOGBASE/searchd.log
USER=`stat -c"%U" /data/$1/current`
COMMAND=""
###############################################################################

export RAILS_ENV="$FRAMEWORK_ENV"
export RACK_ENV="$FRAMEWORK_ENV"
export HOME="/home/$USER"

if [ -f $GEMFILE ]; then
COMMAND="bundle exec"
fi

if [ -d /data/$1/current ]; then

cd /data/$1/current

if [ ! -f $CONFIGFILE ]; then
echo "$CONFIGFILE doesn't exist! Exiting" >> $OUTPUT 2>&1
fi

# handle the second param, don't start if already existing
case "$2" in
start)
echo "Starting searchd"
$COMMAND rake ts:start >> $OUTPUT 2>&1
;;
stop)
echo "Stopping searchd"
$COMMAND rake ts:stop >> $OUTPUT 2>&1
;;
configure)
echo "Configuring your searchd indexes"
$COMMAND rake ts:configure >> $OUTPUT 2>&1
;;
reindex)
echo "Reindexing your searchd indexes against the live server"
$COMMAND rake ts:index >> $OUTPUT 2>&1
;;
*)
usage
;;
esac
else
echo "/data/$1/current doesn't exist."
usage
fi
```

(thanks to Matt Jones at EYDC for that one)