Skip to content

Instantly share code, notes, and snippets.

@mikhailov
Created January 13, 2010 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikhailov/275977 to your computer and use it in GitHub Desktop.
Save mikhailov/275977 to your computer and use it in GitHub Desktop.
Checking the memcached & sphinx running
if $0 == 'script/server'
# Check for memcached
begin
# check if memcached is running; if it is, use that instead of the default memory cache
Timeout.timeout(0.5) { TCPSocket.open("localhost", 11211) { } }
config.cache_store = :mem_cache_store, %w(localhost:11211), { :namespace => 'zimaletto', :timeout => 60 }
$stderr.puts "\033[0;32mUsing memcached on localhost:11211\033[0;34m"
rescue StandardError
$stderr.puts "\033[0;34mmemcached not running, you should run of \033[0;31mmemcached -d -m 128\033[0;29m"
raise
end
# Check for sphinx
begin
# check if memcached is running; if it is, use that instead of the default memory cache
Timeout.timeout(0.5) { TCPSocket.open("localhost", 9312) { } }
$stderr.puts "\033[0;32mUsing sphinx on localhost:9312\033[0;29m"
rescue StandardError
$stderr.puts "\033[0;34msphinx not running, you should run of \033[0;31mrake ts:start\033[0;29m"
raise
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment